没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
试读
1187页
2016,Microsoft Press和Xamarin合作发布了电子书《使用Xamarin.Forms平台开发移动应用:适用于iOS, Android, 和 Windows的跨平台C#编程》,Xamarin.Forms是Xamarin发布的适用于iOS, Android, 和Windows的移动开发平台。 这本书是Xamarin.Forms编程指导的第三版,前两个版本叫做预览版,因为并不全;而第三版共1200页,可谓集Xamarin.Forms之大成。
资源推荐
资源详情
资源评论
CHARLES PETZOLD
Cross-platform C# programming
for iOS, Android, and Windows
Creating
Mobile Apps
with Xamarin.Forms
Celebrating over 30 years!
spine = 1.4063” (per RRDonnelly)
Creating Mobile Apps
with Xamarin.Forms
9781509302970_XamarinCreatingMobileApps_cover_alternate.indd 1 3/24/2016 12:03:49 PM
PUBLISHED BY
Microsoft Press
A Division of Microsoft Corporation
One Microsoft Way
Redmond, Washington 98052-6399
Copyright © 2016 Xamarin, Inc.
All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any
means without the written permission of the publisher.
ISBN: 978-1-5093-0297-0
Printed and bound in the United States of America.
First Printing
Microsoft Press books are available through booksellers and distributors worldwide. If you need support related to
this book, email Microsoft Press Support at mspinput@microsoft.com. Please tell us what you think of this book at
http://aka.ms/tellpress.
This book is provided “as-is” and expresses the author’s views and opinions. The views, opinions and information
expressed in this book, including URL and other Internet website references, may change without notice.
Some examples depicted herein are provided for illustration only and are fictitious. No real association or connec-
tion is intended or should be inferred.
Microsoft and the trademarks listed at http://www.microsoft.com on the “Trademarks” webpage are trademarks of
the Microsoft group of companies. All other marks are property of their respective owners.
Acquisitions and Project Editor: Devon Musgrave
Editorial production: John Pierce, Flying Squirrel Press
Cover illustration: Serena Zhang
Contents
Foreword ................................................................................................................................................................................................. xv
Introduction.......................................................................................................................................................................................... xvi
Chapter 1 How does Xamarin.Forms 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 Xamarin.Forms ......................................................................................................................................................... 8
The Xamarin.Forms option ...................................................................................................................................................... 8
XAML support ............................................................................................................................................................................ 13
Platform specificity ................................................................................................................................................................... 14
A cross-platform panacea? ................................................................................................................................................... 15
Your development environment ............................................................................................................................................. 15
Machines and IDEs ................................................................................................................................................................... 16
Devices and emulators ........................................................................................................................................................... 16
Installation ........................................................................................................................................................................................ 17
Creating an iOS app................................................................................................................................................................. 17
Creating an Android app ....................................................................................................................................................... 18
Creating a Windows app ....................................................................................................................................................... 18
All ready?...................................................................................................................................................................................... 19
Contents iv
Chapter 2 Anatomy of an app ................................................................................................................. 20
Say hello ............................................................................................................................................................................................20
Inside the files .................................................................................................................................................................................24
The iOS project ...........................................................................................................................................................................26
The Android project .................................................................................................................................................................27
The Universal Windows Platform project ........................................................................................................................28
Nothing special! .........................................................................................................................................................................28
PCL or SAP? ......................................................................................................................................................................................29
Labels for text ..................................................................................................................................................................................31
Solution 1. Include padding on the page .......................................................................................................................35
Solution 2. Include padding just for iOS (SAP only) ....................................................................................................36
Solution 3. Include padding just for iOS (PCL or SAP) ...............................................................................................37
Solution 4. Center the label within the page .................................................................................................................39
Solution 5. Center the text within the label ....................................................................................................................41
Chapter 3 Deeper into text ...................................................................................................................... 42
Wrapping paragraphs ..................................................................................................................................................................42
Text and background colors ......................................................................................................................................................44
The Color structure .......................................................................................................................................................................46
Changing the application color scheme ...............................................................................................................................50
Font sizes and attributes .............................................................................................................................................................51
Formatted text ................................................................................................................................................................................53
Chapter 4 Scrolling the stack ................................................................................................................... 60
Stacks of views ................................................................................................................................................................................60
Scrolling content ............................................................................................................................................................................64
The Expands option ......................................................................................................................................................................70
Frame and BoxView ......................................................................................................................................................................74
A ScrollView in a StackLayout? .................................................................................................................................................82
Chapter 5 Dealing with sizes .................................................................................................................... 87
Pixels, points, dps, DIPs, and DIUs ...............................................................................................................................................87
Metrical sizes ...................................................................................................................................................................................96
Contents v
Estimated font sizes ...................................................................................................................................................................... 97
Fitting text to available size ....................................................................................................................................................... 99
A fit-to-size clock........................................................................................................................................................................ 103
Accessibility issues ...................................................................................................................................................................... 105
Empirically fitting text ............................................................................................................................................................... 108
Chapter 6 Button clicks ........................................................................................................................... 113
Processing the click ........................................................................................................................................................................ 113
Sharing button clicks ................................................................................................................................................................. 116
Anonymous event handlers ................................................................................................................................................... 119
Distinguishing views with IDs ................................................................................................................................................ 121
Saving transient data ................................................................................................................................................................ 124
Chapter 7 XAML vs. code ........................................................................................................................ 131
Properties and attributes ......................................................................................................................................................... 132
Property-element syntax ......................................................................................................................................................... 136
Adding a XAML page to your project ................................................................................................................................ 140
The XAML compiler ................................................................................................................................................................... 145
Platform specificity in the XAML file ................................................................................................................................... 146
The content property attribute ............................................................................................................................................. 150
Formatted text ............................................................................................................................................................................. 152
Chapter 8 Code and XAML in harmony ................................................................................................ 156
Passing arguments ..................................................................................................................................................................... 156
Constructors with arguments............................................................................................................................................ 156
Can I call methods from XAML? ...................................................................................................................................... 159
The x:Name attribute ................................................................................................................................................................ 161
Custom XAML-based views .................................................................................................................................................... 167
Events and handlers .................................................................................................................................................................. 172
Tap gestures ................................................................................................................................................................................. 175
Chapter 9 Platform-specific API calls .................................................................................................... 182
Preprocessing in the Shared Asset Project ....................................................................................................................... 182
Parallel classes and the Shared Asset Project .................................................................................................................. 185
剩余1186页未读,继续阅读
duanjn
- 粉丝: 1
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Win64OpenSSL-3-3-0.exe
- 课高分程设计-基于C++实现的民航飞行与地图简易管理系统-南京航空航天大学
- 航天器遥测数据故障检测系统python源码+文档说明+数据库(课程设计)
- 北京航空航天大学操作系统课设+ppt+实验报告
- 基于Vue+Echarts实现风力发电机中传感器的数据展示监控可视化系统+源代码+文档说明(高分课程设计)
- 基于单片机的风力发电机转速控制源码
- 基于C++实现的风力发电气动平衡监测系统+源代码+测量数据(高分课程设计)
- 毕业设计- 基于STM32F103C8T6 单片机,物联网技术的太阳能发电装置+源代码+文档说明+架构图+界面截图
- 基于 LSTM(长短期记忆)(即改进的循环神经网络)预测风力发电厂中风力涡轮机产生的功率+源代码+文档说明
- 基于stm32f103+空心杯电机+oled按键+运动算法
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页