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
Real-world stocks
Design for both
What do they have in common? Windows Phone C# .NET XAML WinRT Windows Same design language
How do they differ? Form factors, mostly Windows Phone 800x480
Landing pages
GridView Panorama Grouped by section Horizontal scrolling PanoramaItem per section Horizontal and vertical scrolling
Lists of data
GridView LongListSelector Horizontal scrolling Optionally grouped Semantic zoom to quickly navigate Vertical scrolling Optionally grouped Jump list to quickly navigate
App bars
AppBar ApplicationBar Top and Bottom Supports circular buttons And/or any content you want Bottom only Supports circular buttons And/or menu items
Back buttons
On screen On device
My personal favorite
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
Develop for both
Sharing an assembly
Portable Class Libraries One Source One Project One Binary Multiple Platforms!
Demo Portable Class Library
Sharing source code
When? XAML Ctrl -C -V Image credit: http://quickmeme.com
Linked files
Linked files Windows Phone Windows Hold Alt and drag a folder to link multiple files at once!
Demo Linked Files
Compiler directives Windows Windows phone #if NETFX_CORE Dispatcher.RunAsync(CoreDispatcherPriority.Normal, myAction); #endif Windows phone #if WINDOWS_PHONE Deployment.Current.Dispatcher.BeginInvoke(myAction); #endif
Demo Compiler Directives
TL;DR: use them both 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?)
Architecture & patterns
Windows Phone Windows Linked App Startup / Lifecycle Views Controls Converters ViewModels Windows App Startup / Lifecycle Views Controls Converters ViewModels Linked Portable Class Library CoreViewModels Services Models
Demo Building real-world stocks
Summary
What to share? PCL Linked source User Interface ü Models ü Business logic ü Web Services ü Helpers ü Logging ✋ View Models (if it makes sense) ✋ Commands (if it makes sense) Linked source ü Converters ü Commands ✋ Controls (if it makes sense) ✋ View Models (if it makes sense) User Interface ü Static assets ü Design language XAML: Not right now
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 Portable HttpClient PCLStorage MetroLog MVVM Caliburn.Micro MVVM Light
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 Store 2-219 – Matthew Cooper – North 134 – 30 minutes from now! Windows Phone Development Best Practices 2-216 – Stefan Wick – North 134 – Friday @ 10:30 AM MVVM In Action – Hulu Case Study 2-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 Rajen Kishna's Technical Tidbits Doug Holland - Sharing Code, MSDN Magazine @dotMorten – Code Sharing Wizard
Drinks and appetizers provided Sharing code meet-up! Drinks and appetizers provided 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
6/3/2018 6:31 AM 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 code to evaluate this session and be automatically entered in a drawing to win a prize! © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.