CreatingMobileAppswithXamarin.Forms
Xamarin的开发教程。基于C#的Xamarin技术,可以用来开发Android,IOS,WP的移动应用。Table of contentsIntroductⅰon。。。。。。Who should read this bookAssumption7Organization of this book7Conventions and features in this book8System reguirements8Downloads: Code samplesUpdatingthe code samples9Acknowledgments..................10Free ebooks from Microsoft Press10We want to hear from you10Chapter 1 How does Amarin. Forms fit in?自自自。自曲Cross-platform mobile deeve/opme12The mobile landscape12Problem 1: Different user-interface paradigms12Problem 2: Different development environments13Problem 3: Different programming interfaces13Problem4: Different programming languages……13The c# and net solution.14A single language for all platforms15Sharing code.16Introducing Amarin Forms18The Amarin Forms option18XAML support…Platform specificity22A cross-platform panacea?Your development environment.23Machines and iDes24Devices and emulators24nsta∥ ation.25Creating an iOS app25Creating an Android app26Creating a Windows Phone app26All ready26Chapter 2 Pages, layouts, and views27Say hello28Anatomy of a Amarin Forms solution ........................30The iOS proj32The android project33The Windows phone project34Nothing special34PCL or SaP?35Labels for text1. Include padding on the page402. Include padding just for iOS3. Center the label within the page4. Center the text within the label .Wrapping paragraphs45Text and background colorsThe color structure.49Standard fonts and sizes.52Formatted textStacks of views57Scrolling content.60The layout expand option65frame and boxview69A Scrol/view in a StackLayout?The button for commands78Sharing button clicks.81Anonymous event handlers.83Distinguishing views with IDs85Chapter 3 Building an app: Infrastructure●·····。。。。非非。。。·89Version 1. The entry and Editor views91Version 2. File input/output.....................95Skip past the scary stuff?97Preprocessing in the Sap97Dependency service in the PCL102Version 3. Going async.106Asynchronous lambdas in the SAP109Method callbacks in the pcl114Version 4. will notify you when the property changes119Version 5. Data binding126Streamlininga peek into Bindable Object and bindable properties130Automated data bindings133Version 6. Awaiting results137What's next?150Chapter 4 Building an app: Architecture151Version 7. Page navigation151Version 8. Notes in the listview157Enumerating file159The list∨ⅰeW….162Version 9. Editing and deleting169Version 10. Adding a template cell175Version 11. Constructing a toolbar178cons for android…179Icons for windows phone180Icons for ioS devices180Toolbarltem code181Version 12. Application lifecycle events185The ios implementation188The android implementation188The Windows Phone implementation190Saving and restoring191Making it pretty.195Chapter 5 Principles of presentation...197The Amarin Forms class hierarchy197Pixels, points, dps, DIPs, and D/Us203Estimated font sizes208Programmer's first clock app213Image and bitmaps215absolute layout and attached bindable properties221Absolutelayout proportionally229Chapter 6 The interactive interface233View overview主Slider, Stepper, and Switch234主Data binding238Date and time selection245Custom views. a radio button248Mastering the grid257The Grid and attached bindable properties.............262IntroductionThis is a Preview Edition of a book about writing applications for Xamarin Forms, the exciting newmobile development platform for iOS, Android, and Windows Phone unveiled by Xamarin in May 2014Xamarin Forms lets you write shared user-interface code in C# and XAML (the eXtensible ApplicationMarkup Language) that maps to native controls on these three platformsThis book is a Preview Edition because it's not complete. It has only six chapters. We anticipate thatthe final version of the book will have at least half a dozen additional chapters and that the chapters inhis Preview Edition might be fleshed out, enhanced, or completely reconceived. The final edition ofthe book will probably be published in the spring of 2015Who should read this bookThis book is for C# programmers who want to write applications for the three most popular mobileplatforms: iOS, Android, and Windows Phone with a single code base. Amarin Forms also hasapplicability for those programmers who want eventually to use C# and the Amarin ios andXamarin. Android libraries to target the native application programming interfaces(APls)of theseplatforms. Xamarin Forms can be a big help in getting started with these platforms or in constructing aprototype or proof-of-concept applicationAssumptionsThis book assumes that you know C# and have some familiarity with the use of the. NET FrameworkHowever, when I discuss some C# and. NeT features that might be somewhat new to recent C#programmers, I adopt a somewhat slower pace. In particular, the introduction of the async keywordand await operator in Chapter 3 follows a discussion that shows how to do asynchronousprogramming using traditional callback methodsOrganization of this bookThis book is intended as a tutorial to learn Xamarin Forms programming. It is not a replacement for theonline aPl documentation, which can be found here under the heading Amarin Forms framework onthispagehttp://api.xamarin.comThis Preview Edition's Chapter 1 discusses Xamarin Forms in the larger context of mobile developmentand the Amarin platform and also covers the hardware and software configurations you'll needChapter 2 explores some of the basics of Xamarin Forms programming, including the use of Label,Button, and stacklayoutIn Chapters 3 and 4, however, I tried to do something a little different: These chapters show theprogressive step-by-step development of a small Xamarin Forms application. Despite the simplicity ofthis program, it is in many ways a"real"application, and requires essential real-app facilities such as file10 and application lifecycle handling both of which turned out to be somewhat more challengingthan i originally anticipated I'm curious to hear whether these two chapters"work"or not. See thesection below on submitting feedback to usChapters 5 and 6 return to more conventional API tutorials. My biggest regret is that I wasnt able toget some coverage of XAML into this Preview Edition. However, the Xamarin website has someadditional resources for learning Xamarin. Forms including a six-part"XAML for Xamarin Formsdocumenthttp://developer.xamarin.com/quides/cross-platform/xamarin-forms/Conventions and features in this bookThis book has just a few typographical conventionsAll programming elements referenced in the text--including classes, methods, properties,variable names, etc -are shown in a monospaced font, such as the StackLayout classItems that appear in the user interface of visual Studio or Xamarin Studio, or the applicationsdiscussed in these chapters, appear in boldface, such as the Add New Project dialogApplication solutions and projects also appear in boldface, such as Color ScrollSystem requirementsThis book assumes that you 'll be using Xamarin Forms to write applications that simultaneously targetlI three supported mobile platforms--iOS, Android and Windows Phone. However, it's very likely thatmany readers will be targeting only one or two platforms in their Xamarin Forms solutions. Theplatforms you target--and the Amarin Platform package you purchase--govern your hardware andsoftware requirements. For targeting ioS devices, you 'll need a Mac installed with Apple XCode as wellas the Xamarin Platform, which includes Xamarin Studio For targeting Windows Phone, you'll needVisual Studio 2012 or 2013(not an Express Edition) on a PC, and you'll need to have installed theAmarin PlatformHowever, you can also use visual Studio on the pc to target ios devices if the mac with XCode andthe Amarin Platform is accessible via WiFi. You can target android devices from Visual Studio on thePC or from Xamarin Studio on either the pc or macChapter 1 has more details on the various configurations you can use, and resources for additionainformation and support. My setup for creating this book consisted of a microsoft Surface Pro 2(withexternal monitor, keyboard and mouse)installed with Visual Studio 2013 and the Xamarin Platform8connected by WiFi with a MacBook Pro installed with XCode and the Xamarin PlatformDownloads: Code samplesThe sample programs shown in the pages of this book were compiled in early September with version1.2. 2.6243 of Amarin Forms. The source code of these samples is hosted on a repository on GitHubhttps://github.com/xamarin/xamarin-forms-book-preview/You can clone the directory structure to a local drive on your machine, or download a big ZiP file. I'lItry to keep the code updated with the latest release of Xamarin. Forms and to fix(and comment)anyerrors that might have sneaked throughYou can report problems, bugs, or other kinds of feedback about the book or source code byclicking the issues button on this github page you can search through existing issues or file a newone. To file a new issue, you' ll need to join GitHub(if you haven 't already)Use this gibHub page only for issues involving the book. For questions or discussions aboutXamarin.FormsitselfusetheXamarin.Formsforumhttp://forums.xamarin.com/categories/xamarinformsUpdating the code samplesThe libraries that comprise Xamarin. Forms are distributed via the Nuget package manager. TheXamarin Forms package consists of five dynamic-link libraries: Xamarin Forms Core. dllXamarin Forms Xaml. dll Amarin Forms PlatformiOS. dll, Amarin Forms platform. Android. dll, andXamarin Forms Platform. WP8.dll. The Amarin Forms package also requires Xamarin Support Library v4(Amarin Android Support V4. dll)and the Windows Phone Toolkit(Microsoft Phone ControlsToolkit dID), which should be automatically includedWhen you create a new Xamarin. Forms solution using Visual Studio or Amarin Studio, a version ofthe Amarin Forms package becomes part of that solution. However, that might not be the latestXamarin Forms package available from NuGet. Here's how to update that packageIn Visual Studio, right-click the solution name in the Solution Explorer and select Manage NuGetPackages for Solution. Select Installed packages at the left of the dialog to see what's currentlyinstalled, and Updates and nuget. org at the left to choose to update the package. If an update isavailable clicking the update all button is easiest to get it into the solutionn Xamarin Studio, in the individual projects in the solution list, under Packages, select theXamarin Forms package and select Update from the tool dropdownThe source code for this book that is stored on gitHub does not include the actual NuGet packagesXamarin Studio will automatically download them when you load the solution but visual studio willnot. After you first load the solution into Visual Studio, right-click the solution name in the Solution
用户评论
midwife47139 2019-05-07 15:59:28
很好的书,有例子,详细。
Delete25720 2019-05-07 15:59:28
对于初学者来说不错,不过就是英文还是痛啊
wangha85555 2019-05-07 15:59:28
值得一读,刚学Xamarin,对Xamarin.Forms很感兴趣,只不过全英文比较费劲
qqpassionate40604 2019-05-07 15:59:28
的确不错,如果是中文就更好了!