![Page 1: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/1.jpg)
Developing Multi Targetting Win8 & WP8 Apps.Jose Luis LatorreSenior Developer, Accenture UI Lead Developer, Roche [email protected] - @joslat http://silverlightguy.com
![Page 2: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/2.jpg)
Agenda
Agenda
The importance of Multi Targeting5’
ABC of Multi Targeting 10’MVVM 5’Creating our Multi Targeting App25’ Creating the Multi Targeting “base application” Getting data from the web Using a shared user control
Summarizing + Q & A 5’
![Page 3: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/3.jpg)
The Importance of Multi TargetingIt is important. that’s why you are here, right?
![Page 4: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/4.jpg)
.NET
C#, VB
Windows Phone 7.x
Direct3D, XAudio2, MF,
WASAPI, WIN32, COM
C++
Windows Phone APIWindows Phone 8
Windows Phone
Runtime
C#, VB, C++
![Page 5: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/5.jpg)
Your appsYour way
Windows Phone 8 Developer Platform
XAML Apps Direct3D Apps
XAML Maps Geolocation Sensors In-App Purchase Direct3D
HTML XML Threading Touch Speech XAudio2
Phone Features Push Camera Video Proximity Media
Foundation
Calendar Wallet Contacts Core Types VoIP STL
Multitasking Live Tiles Memory Async Enterprise CRT
C# and VB C#, VB, and C++ C++
File system, Networking, Graphics, Media
Core Operating System
![Page 6: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/6.jpg)
Investment in Windows Runtime API
NetworkingProximityIn-App PurchaseSensorsLocationFile SystemCore app modelThreading
11,000 members
2,800 shared
members
![Page 7: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/7.jpg)
Good Reasons for Multi Targetting..
![Page 8: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/8.jpg)
ABC of Multi TargetingLet’s see the main points on how to do it right, the first time.
![Page 9: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/9.jpg)
Best practices & Patterns
• Share code across platforms using Portable Class Libraries
• Share resources and code, whenever possible
• Apply MVVM to wire cross-platform apps• Create portable abstractions for non-
portable functionality• Use Service Locator and IoC container to hook up the implementations.• Other patterns apply as well, like Repository.
![Page 10: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/10.jpg)
Best practices & Patterns
• Link Source code files between platforms.
• Whenever the implementation is equal or very similar.• Use compiler directives for jumping over the light differences.
• Create platform specific Views• To maximize the user experience in the UI
• Share UI with user controls • But only if it doesn’t reduce the user experience
• Always Decouple! Create Clean & SOLID Code.
• And remember fundamental OOP principles, KISS & DRY.• Avoid STUPID code.
![Page 11: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/11.jpg)
web services
portable class library
![Page 12: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/12.jpg)
Creating a Portable Class Library
![Page 13: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/13.jpg)
One SourceOne ProjectOne Binary
Multiple Platforms!
Portable Class Libraries
![Page 14: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/14.jpg)
Common StructureWindows 8 Windows Phone
8
![Page 15: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/15.jpg)
“Add as Link”
![Page 16: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/16.jpg)
“Add as Link”Windows 8 Windows Phone 8
![Page 17: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/17.jpg)
#if Conditional BlocksWindows 8#if NETFX_COREDispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {#endif
#if WINDOWS_PHONEDeployment.Current.Dispatcher.BeginInvoke(() => {#endif
Windows Phone 8
![Page 18: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/18.jpg)
public class ServiceLocator
{
public static IFileStorage FileStorage { get; set; }
public static IPhotoChooser PhotoChooser { get; set; }
}
Simple service locator
![Page 19: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/19.jpg)
MVVMIt deserves its own section on this XAML world.
![Page 20: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/20.jpg)
Separate UI from app logic
User Interface
App Logic
General Model-View-ViewModel (MVVM)
![Page 21: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/21.jpg)
Model-View-ViewModel (MVVM)
ViewsHow to display informationWritten in XAML
View ModelsWhat information to displayFlow of interaction
ModelsData objectsBusiness logicEtc.
Model
View Model
View Platform-specific
PortableReferences
Databinds
![Page 22: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/22.jpg)
MVVM Cross-platform app architecture
Startup
Views
Windows Store App
Platform specific functionality
View Models
Models
Portable Class Library
Platform functionality abstractions
Startup
Views
Windows Phone App
Platform specific functionality
Reference Reference
![Page 23: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/23.jpg)
Creating our Multi Targeting AppWe will see how to create a Windows Store & Windows Phone App that share code and components.
![Page 24: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/24.jpg)
Interesting points from base app• Usage of PCL to share code• Portable.MvvmLightLibs &
Portable.CommonService Locator• MVVM done right• Linking code
![Page 25: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/25.jpg)
OData Service Access implementation• Usage of the Repository pattern• Creation of our first ViewModel• OData Client Tools for Windows Store &
Windows Phone Apps (http://msdn.microsoft.com/en-us/jj658961)
![Page 26: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/26.jpg)
Odata Service implementation
Do not trust the web…
![Page 27: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/27.jpg)
Summary..So, what have we seen?
![Page 28: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/28.jpg)
What have we seen?
Applying best practices is a mustUsing proper design patterns tooSharing Code through PCL & LinkingMVVM is fundamental
Best Practices
PCL – Portable Class Libraries
Design Paterns
MVVM is fundamental
![Page 29: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/29.jpg)
Jose Luis LatorreEmail: [email protected] Twitter: @joslat Blog: http://Silverlightguy.com
![Page 30: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/30.jpg)
![Page 31: Shape 2013 developing multi targeting windows store and windows phone apps](https://reader033.vdocuments.net/reader033/viewer/2022052907/558fd8881a28ab6c368b460e/html5/thumbnails/31.jpg)
© 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista 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.