470 likes | 641 Views
Build for both: Windows and Windows Phone. Matt Hidinger Clarity Consulting 2-215. So umm… you’re not with Microsoft?. Clarity Consulting Windows Phone Dev MVP. But first… a phone!. Sharing. Design for both Develop for both Architecture & patterns. Image credit: Jason Emprey.
E N D
Build for both: Windows and Windows Phone Matt Hidinger Clarity Consulting 2-215
So umm… you’re not with Microsoft? • Clarity Consulting • Windows Phone Dev MVP
Sharing • Design for both • Develop for both • Architecture & patterns Image credit: Jason Emprey
C#.NETXAMLWinRT • Same design language • What do they have in common? Windows
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
Inspiration is everywhere • Design is more than the appearance • Tune the experience and use cases for the form factor • Pay attention to the details, modern design isn’t lack of design
Portable Class Libraries • One Source • One Project • One Binary • Multiple Platforms!
Demo • Portable Class Library
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
Demo • Linked Files
Compiler directives Windows • #if NETFX_CORE • Dispatcher.RunAsync(CoreDispatcherPriority.Normal, myAction); • #endif Windows phone #if WINDOWS_PHONE Deployment.Current.Dispatcher.BeginInvoke(myAction); #endif
Demo • Compiler Directives
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?)
Demo • Building real-world stocks
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 Caliburn.Micro MVVM Light • Portable • HttpClient • PCLStorage • MetroLog
Try it yourself! • Download the full source for this talk in a few days • http://bit.ly/BuildRealWorldStocks
Related sessions • Story of Nokia Music, from Windows Phone to Windows Store2-219 – Matthew Cooper – North 134 – 30 minutes from now! • Windows Phone Development Best Practices2-216 – Stefan Wick – North 134 – Friday @ 10:30 AM • MVVM In Action – Hulu Case Study2-205 – Matthias Shapiro – North 134 – Friday @ 12:00 PM
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
Drinks and appetizers provided • Sharing code meet-up! • Join other speakers and Microsoft employees to talk about sharing • Today @ 6 PM • Microsoft Office • 835 Market Street, Suite 700
Thank you!Q&A • @MattHidinger
Required Slide *delete this box when your slide is finalized Your MS Tag will be inserted here during the final scrub. Evaluate this session • Scan this QR codeto evaluate this session and be automatically entered in a drawing to win a prize!