Creating Mobile Apps With Xamarin Forms Pdf
کتاب Creating Mobile Apps with Xamarin.Forms.pdf
دانلود رایگان کتاب Creating Mobile Apps with Xamarin.Forms.pdf
CHARLES PETZOLD
Microsoft Press
دانلود رایگان کتاب Creating Mobile Apps with Xamarin.Forms.pdf
Table of contents
Introduction viii
Who should read this book viii
Conventions and features in this book viii
The 1st and 2nd Preview Editions ix
System requirements ix
Downloads: Code samples x
Updating the code samples x
Big changes coming for Windows Phone xi
Acknowledgments xi
Free ebooks from Microsoft Press xii
We want to hear from you xii
Chapter 1 How does XamarinForms fit in? 1
Cross-platform mobile development 2
The mobile landscape 2
Problem 1: Different user-interface paradigms 2
Problem 2: Different development environments 3
Problem 3: Different programming interfaces 3
Problem 4: Different programming languages 3
The C# and NET solution 4
A single language for all platforms 5
Sharing code 6
Introducing XamarinForms 8
The XamarinForms option 8
XAML support 10
Platform specificity 12
A cross-platform panacea? 12
Your development environment 13 Machines and IDEs 13
Devices and emulators 14
Installation 14
Creating an iOS app 15
Creating an Android app 15
Creating a Windows Phone app 16
All ready? 16
Chapter 2 Anatomy of an app 17
Say hello 17
Inside the files 20
The iOS Project 23
The Android project 23
The Windows Phone project 24
Nothing special! 25
PCL or SAP? 25
Labels for text 27
1 Include padding on the page 31
2 Include padding just for iOS (Shared Asset Project only) 32
3 Include padding just for iOS (PCL or SAP) 33
4 Center the label within the page 35
5 Center the text within the label 37
Chapter 3 Deeper into text 38
Wrapping paragraphs 38
Text and background colors 40
The Color structure 42
Font sizes and attributes 46
Formatted text 47
Chapter 4 Scrolling the stack 54
Stacks of views 54
Scrolling content 58 The Expands option 64
Frame and BoxView 68
A Scroll View in a StackLayout? 76
Chapter 5 Dealing with sizes 81
Pixels, points, dps, DIPs, and DIUs 81
Metrical sizes 88
Estimated font sizes 89
Fitting text to available size 92
A fit-to-size clock 96
Empirically fitting text 98
Chapter 6 Button clicks 103
Processing the click 103
Sharing button clicks 106
Anonymous event handlers 109
Distinguishing views with IDs 111
Saving transient data 114
Chapter 7 XAML vs code 121
Properties and attributes 122
Property-element syntax 126
Adding a XAML page to your project 130
Platform specificity in the XAML file 135
The content property attribute 139
Formatted text 141
Chapter 8 Code and XAML in harmony 145
Passing arguments 145
Constructors with arguments 145
Can I call methods from XAML? 148
The x:Name attribute 150
Custom XAML-based views 156
Events and handlers 160Tap gestures163
Chapter 9 Platform-specific API calls 170
Preprocessing in the Shared Asset Project 170
Parallel classes and the Shared Asset Project 173
DependencyService and the Portable Class Library 175
Platform-specific sound rendering 179
Chapter 10 XAML markup extensions 186
The code infrastructure 186
Accessing static members 188
Resource dictionaries 194
StaticResource for most purposes 195
A tree of dictionaries 201
DynamicResource for special purposes 205
Lesser-used markup extensions 208
A custom markup extension 209
Chapter 11 The bindable infrastructure 214
The XamarinForms class hierarchy 215
A peek into BindableObject and BindableProperty 221
Defining bindable properties 228
The generic Create method 233
The read-only bindable property 234
Chapter 12 Styles 240
The basic Style 240
Styles in code246
Style inheritance 247
Implicit styles 252
Dynamic styles 257
Device styles 264
Chapter 13 Bitmaps 269
Platform-independent bitmaps 270Fit and fill 273
Embedded resources 275
More on sizing 281
Browsing and waiting 292
Streaming bitmaps 296
Accessing the streams 297
Generating bitmaps at run time 299
Platform-specific bitmaps 303
Bitmap resolutions 305
Toolbars and their icons 312
Button images 319
Chapter 14 Absolute layout 322
AbsoluteLayout in code 323
Attached bindable properties 328
Proportional sizing and positioning 332
Working with proportional coordinates 334
AbsoluteLayout and XAML 339
Overlays 343
Some fun 346
Chapter 15 The interactive interface 355
View overview 355
Slider and Stepper 356
Slider basics 356
Common pitfalls 359
Slider color selection 361
The Stepper difference 365
Switch and CheckBox 368
Switch basics 368
A traditional CheckBox 370
Typing text 375Keyboard and focus 376
Choosing the keyboard 377
Entry properties and events 379
The Editor difference 385
The SearchBar 389
Date and time selection 394
The DatePicker 395
The TimePicker (or is it a TimeSpanPicker?) 398
Chapter 16 Data binding 402
Binding basics 402
Code and XAML 404
Source and BindingContext 407
The binding mode 414
String formatting 419
Why is it called "Path"?422
Binding value converters 425
Bindings and custom views 433
Introduction
This is the second Preview Edition of a book about writing applications for XamarinForms, the exciting new mobile development platform for iOS, Android, and Windows Phone unveiled by Xamarin in May 2014 XamarinForms lets you write shared user-interface code in C# and XAML (the Extensible Applica-tion Markup Language) that maps to native controls on these three platforms
This book is a Preview Edition because it's not complete It has only 16 chapters and doesn't cover some important topics The final edition of the book will probably be published in the summer of 2015
Who should read this book
This book is for C# programmers who want to write applications for the three most popular mobile platforms—iOS, Android, and Windows Phone—with a single code base XamarinForms also has ap-plicability for those programmers who want eventually to use C# and the XamariniOS and Xama-rinAndroid libraries to target the native application programming interfaces (APIs) of these platforms XamarinForms can be a big help in getting programmers started with these platforms or in construct-ing a prototype or proof-of-concept application
This book assumes that you know C# and are familiar with the use of the NET Framework However, when I discuss some C# and NET features that might be somewhat new to recent C# programmers, I adopt a somewhat slower pace
Conventions and features in this book
This book has just a few typographical conventions:
All programming elements referenced in the text—including classes, methods, properties, varia-ble names, etc—are shown in a monospaced font, such as the StackLayout class
Items that appear in the user interface of Visual Studio or Xamarin Studio, or the applications discussed in these chapters, appear in boldface, such as the Add New Project dialog
Application solutions and projects also appear in boldface, such as MonkeyTap
System requirements
This book assumes that you'll be using XamarinForms to write applications that simultaneously target all three supported mobile platforms—iOS, Android, and Windows Phone However, it's very likely that many readers will be targeting only one or two platforms in their XamarinForms solutions The plat-forms you target—and the Xamarin Platform package you purchase—govern your hardware and soft-ware requirements For targeting iOS devices, you'll need a Mac installed with Apple Xcode as well as the Xamarin Platform, which includes Xamarin Studio For targeting Windows Phone, you'll need Visual Studio 2012 or later (not an Express Edition) on a PC, and you'll need to have installed the Xamarin Platform
However, you can also use Visual Studio on the PC to target iOS devices if the Mac with Xcode and the Xamarin Platform are accessible via WiFi You can target Android devices from Visual Studio on the PC or from Xamarin Studio on either the PC or Mac
Chapter 1 has more details on the various configurations you can use and resources for additional information and support My setup for creating this book consisted of a Microsoft Surface Pro 2 (with external monitor, keyboard, and mouse) installed with Visual Studio 2013 and the Xamarin Platform, connected by WiFi with a MacBook Pro installed with Xcode and the Xamarin Platform
All the screen shots in this book show an iPhone, an Android phone, and a Windows Phone in that order The three devices shown in these screen shots reflect my setup and hardware:
The iPhone 6 simulator on the MacBook Pro running iOS 82
An LG Nexus 5 running Android 51
A Nokia Lumia 925 running Windows Phone 81
Some of the early screen shots in this book were from devices with somewhat earlier versions of the operating systems, for example Android 50 or 501 rather than 51
The XamarinForms programs in this book target the XamariniOS Unified API and the Windows Phone 80 Silverlight API (More about the Windows Phone API shortly)
How does XamarinForms fit in?
There is much joy in programming There is joy in analyzing a problem, breaking it down into pieces, formulating a solution, mapping out a strategy, approaching it from different directions, and crafting the code There is very much joy in seeing the program run for the first time, and then more joy in ea-gerly diving back into the code to make it better and faster
There is also often joy in hunting down bugs, in ensuring that the program runs smoothly and pre-dictably Few occasions are quite as joyful as finally identifying a particularly recalcitrant bug and defin-itively stamping it out
There is even joy in realizing that the original approach you took is not quite the best Many devel-opers discover that they've learned a lot writing a program, including that there's a better way to struc-ture the code Sometimes, a partial or even a total rewrite can result in a much better application The process is like standing on one's own shoulders, and there is much joy in attaining that perspective and knowledge
However, not all aspects of programming are quite so joyful One of the nastier programming jobs is taking a working program and rewriting it in an entirely different programming language or porting it to another operating system with an entirely different application programming interface (API)
A job like that can be a real grind Yet, such a rewrite may very well be necessary: an application that's been so popular on the iPhone might be even more popular on Android devices, and there's only one way to find out
But here's the problem: As you're going through the original source code and moving it to the new platform, do you maintain the same program structure so that the two versions exist in parallel? Or do you try to make improvements and enhancements?
The temptation, of course, is to entirely rethink the application and make the new version better But the further the two versions drift apart, the harder they will be to maintain in the future.
For this reason, a sense of dread envelopes the forking of one application into two With each line of code you write, you realize that all the future maintenance work, all the future revisions and en-hancements, have become two jobs rather than one.
This is not a new problem For over half a century, developers have craved the ability to write a sin-gle program that runs on multiple machines This is one of the reasons that high-level languages were invented in the first place, and this is why the concept of "cross-platform development" continues to exert such a powerful attraction for programmers.
دانلود رایگان کتاب Creating Mobile Apps with Xamarin.Forms.pdf
Creating Mobile Apps With Xamarin Forms Pdf
Source: http://www.projanco.com/%D9%8Earticles/%DA%A9%D8%AA%D8%A7%D8%A8%D8%AE%D8%A7%D9%86%D9%87/616-creating-mobile-apps-with-xamarin-forms-pdf
0 Response to "Creating Mobile Apps With Xamarin Forms Pdf"
Post a Comment