420 likes | 525 Vues
Build for both: Windows and Windows Phone. Tim Chaffee. Inspired by and created from Build talk by: Matt Hidinger. http://channel9.msdn.com/Events/Build/2013/2-215. Who is Tim Chaffee?. Developer Consultant Hardware (toys) enthusiast tchaffee@darktowerconsulting.com @ TimChaffee.
E N D
Build for both: Windows and Windows Phone Tim Chaffee
Inspired by and created fromBuild talk by: Matt Hidinger http://channel9.msdn.com/Events/Build/2013/2-215
Who is Tim Chaffee? Developer Consultant Hardware (toys) enthusiast tchaffee@darktowerconsulting.com @TimChaffee
Sharing • Design for both • Develop for both • Architecture & patterns Image credit: Jason Emprey
C#.NETXAMLWinRT • What do they have in common? • Same design language
Form factors, mostly Windows 1024x768 …to… 3200x1800+ ??? • Windows Phone • 800x480 • 1280x768 • 1280x1024 • ??? • How do they differ?
GridView Panorama Grouped by section Horizontal scrolling PanoramaItem per section Horizontal and vertical scrolling
LongListSelector GridView Horizontal scrolling Optionally grouped Semantic zoom to quickly navigate Vertical scrolling Optionally grouped Jump list to quickly navigate
ApplicationBar AppBar Top and Bottom Supports circular buttons And/or any content you want Bottom only Supports circular buttons And/or menu items
On device On screen
Good Design takes work and planning • Design is more than the appearance • Tune the experience and use cases for the form factor • Pay attention to the details, the better designed apps will get more usage
Shameless Plug • BuzzWord
Portable Class Libraries • One Source • One Project • One Binary • Multiple Platforms!
What is supported? NUGET
When? XAML -C -V • Ctrl • Ctrl Image credit: http://quickmeme.com
Linked files • Hold Alt and drag a folder to link multiple files at once! Windows Phone Windows
Compiler directives Windows • #if NETFX_CORE • Dispatcher.RunAsync(CoreDispatcherPriority.Normal, myAction); • #endif Windows phone #if WINDOWS_PHONE Deployment.Current.Dispatcher.BeginInvoke(myAction); #endif
Comparison • Sharing an assembly (PCL) • • Code remains clean and single purpose • Build, test, compile once • • Limited API access • Can’t reference non-PCL assemblies • Won’t work with Express SKUs Sharing source code (linked files) Full API access on the platform compiling it Can tweak source per platform using #if Code can become complex due to compiler directives Minor Visual Studio quirks: “This document is already open” TL;DR: use them both
Use your skills, Luke • You know C# • You know .NET • You know and love XAML (right?)
????? Linked
What to share? User Interface üStatic assets üDesign language XAML: Not right now Linked source üConverters üCommands ✋Controls (if it makes sense) ✋View Models (if it makes sense) PCL üModels üBusiness logic üWeb Services üHelpers üLogging ✋View Models (if it makes sense) ✋Commands (if it makes sense)
Mix and match techniques • Architect with sharing in mind • Put as much into a PCL as possible • Use a platform adapter to Do More in Core • Use #if conditions for minor code differences • Extension methods can bridge missing APIs • Maximize the user experience for each platform Image credit: Daniel E Lee
Beneficial frameworks MVVM MVVM Light MVVM Cross • Portable • HttpClient • Json.NET • ZXing
Try it yourself! • http://channel9.msdn.com/Events/Build/2013/2-215 • http://bit.ly/BuildRealWorldStocks
What about that other “platform” • http://xamarin.com XamariniOS Xamarin Android
References • Daniel Plaisted - Making Portable Libraries Work For You • Matthias Shapiro – TechEd 2013, Build It Once For Both • RajenKishna's Technical Tidbits • Doug Holland - Sharing Code, MSDN Magazine • @dotMorten – Code Sharing Wizard
Thank you!Q&A • @TimChaffee
Sphero http://www.gosphero.com/Discount Code: FloridaNETDev