Top 10 Differences between developing Windows Phone and Store apps

22,460 views
21,963 views

Published on

Slides from IE Hackathon session (June 8 2013) on the differences between the Windows Phone and Windows Store APIs.

Published in: Technology, Education
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
22,460
On SlideShare
0
From Embeds
0
Number of Embeds
12,829
Actions
Shares
0
Downloads
0
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide
  • System.Windows vs. Windows.UI.Xaml....System.Windows.MarkupWindows.UI.Xaml.MarkupSystem.Windows.MediaWindows.UISystem.SizeWindows.Foundation.SizeSystem.WindowsWindows.FoundationBe careful though:System.Windows.Media.Color vs. Windows.UI.Color: Exists on WP, but comes from WinRT types (+there's also an XNA version)
  • Pointers vs. MouseSystem.Windows.Input.MouseEventHandlerWindows.UI.Xaml.Input.PointerEventHandler WP: (Double)Tap, WinStore: (Double)Tapped WP: MouseLeftButtonDown, WinStore: PointerPressed
  • System.Windows.Input.MouseEventHandlerWindows.UI.Xaml.Input.PointerEventHandler WP: (Double)Tap, WinStore: (Double)Tapped WP: MouseLeftButtonDown, WinStore: PointerPressed
  • (use NuGet package, but no compression).. Include link to Gzip code + pcl
  • Switching to Dispatcher threadDispatcher.HasThreadAccessvsCheckAccess(), BeginInvoke, RunAsyncvar dispatcher = System.Windows.Deployment.Current.Dispatcher; var dispatcher = Windows.UI.Xaml.Window.Current.Dispatcher;
  • WinStoreWindows.ApplicationModel.DesignMode.DesignModeEnabledWinPhoneSystem.ComponentModel.DesignerProperties.IsInDesignTool WPF System.ComponentModel.DesignerProperties.GetIsInDesignMode(UIElement)
  • WinStoreWindows.ApplicationModel.DesignMode.DesignModeEnabledWinPhoneSystem.ComponentModel.DesignerProperties.IsInDesignTool WPF System.ComponentModel.DesignerProperties.GetIsInDesignMode(UIElement)
  • Different parameterMultipleFramesBack button vs hooking up backspace.
  • Different parameterMultipleFramesBack button vs hooking up backspace.
  • Snap View. Privacy Policy
  • WinPhone: Roaming settingsWinRT UI Stack Remote Debugging via Wifi No DWrite or Direct2D on WinPhoneWinStore:WriteableBitmap.Render()RadialBrushes XNA LOB Company Hub APIs (was told “Wait for //build/ conference” this week) Rich Binding support Remote debugging via USB (issue with some wifi networks) See article http://www.itwriting.com/blog/6779-how-to-test-and-debug-an-app-on-surface-rt-in-a-hotel-room.html Build apps using JavaScript (PhoneGap for WP if you really want to)Behaviors
  • Top 10 Differences between developing Windows Phone and Store apps

    1. 1. Windows Store & Phone Devtop 10 differences@dotMorten
    2. 2. Who’s who?WindowsPhonePlatform of choiceC# since .NET 1.0 beta 2XAML fulltime since Silverlight v1.1Work: Building SDKs formappingSilverlight, WPF, WindowsPhone, Windows StoreHobby:Same thing but I get to be boss Windows 8WPF
    3. 3. Who’s who #2What is your preferred coding language?C#VB.NETJavaScriptC++OtherWhat platform do you develop most for?Windows 8Windows PhoneWPFWindows FormsOther
    4. 4. The Inspiration for This Talk• ArcGIS Runtime SDK for WindowsA Mapping SDK for Windows Phone, Store and Desktop.Core runtime (C++ & DirectX)C++ interopC++/CX WinRT APIC# importsPublic .NET SDK (C#)Store Phone Desktop
    5. 5. Use Portable Class Library if you canPro:Build, test and compile once.Con:Won’t work for UI codeCan’t use non-PCL librariesNo Platform specific codeUse shared source only when you can’tPro:Can always fully use the platform.Can use non-PCL componentsCon:Likely more testing involved.Visual Studio gets a little “weird” about it.More stuff to compileOr… use them both!But why share source?
    6. 6. PCL And Shared Source TogetherWindows Phone8Portable Class LibrariesWindows 8ServicesViewModels (limited or abstract)ModelsViews (XAML)App LifecycleNavigationViews (XAML)ConvertersShared ViewModels (Add as Link)Storage, AlertsPlatform SpecificDifferent XAMLDifferent ControlsSame DataBindingsSame Commands forKey InteractionsConverters
    7. 7. Quick Code Share Demo
    8. 8. sounds too good to be true?99% harpmusicIt almost is...At least 99% shared code.What’s in the remaining 1%?1% drums
    9. 9. #if NETFX_CORE //Store#elif WINDOWS_PHONE //Phone#elif SILVERLIGHT //Silverlight or Phone#else //WPF/Desktop#endifOr combine them:#if NETFX_CORE || WINDOWS_PHONE#if !SILVERLIGHT#if SILVERLIGHT && !WINDOWS_PHONEEncapsulate platform specific code using#if [conditional]
    10. 10. 1. Namespaces#if NETFX_COREusing Windows.UI.Xaml;#elseusing System.Windows;#endifPhone / WPF / Silverlight Windows StoreSystem.Windows Windows.UI.XamlSystem.Windows.Media Windows.UISystem Windows.Foundation*SystemSystem.Size Windows.Foundation.Size*System.Windows.Media.ColorWindows.UI.ColorMicrosoft.Xna.Framework.Graphics.ColorWindows.UI.Color
    11. 11. Windows Phone/WPF/Silverlightxmlns:local="clr-namespace:MyNamespace;assembly=MyApp"Windows Store XAMLxmlns:local="using:MyNamespace"2. XAML Namespace declaration
    12. 12. 3. Touch/Mouse/PenTouch is kind oflike a mouseEverything isjust a pointer
    13. 13. Windows Phone Windows StoreMouseEventHandler => PointerEventHandlerMouseLeftButtonDown => PointerPressedMouseMove => PointerMovedMouseEnter/Exit => PointerEntered/ExitedTap => TappedDoubleTap => DoubleTappedHold => Holding3. Touch/Mouse/Pen #2
    14. 14. Windows Phone:Make web requests using “WebClient”Install NuGet package “Microsoft.Net.Http”Windows Store:Make web requests using “HttpClient”4. HttpClient vs. WebClientHttpClient
    15. 15. Use the Dispatcher to call the UI ThreadHowever they look different...5. The Dispatcher
    16. 16. Windows PhoneWindows Store:5. The Dispatcher #2
    17. 17. 5. The Dispatcher #3
    18. 18. public class MyViewModel{public MyViewModel(){if(IsDesign) // <- different on every platformMyProperty = "Lorem Ipsum";elseGenerateData();}public string MyProperty { get; set; }…}6. Generating Design Time Data
    19. 19. public bool IsDesign{get{#if NETFX_COREreturn Windows.ApplicationModel.DesignMode.DesignModeEnabled;#elif SILVERLIGHT // includes WINDOWS_PHONEreturn System.ComponentModel.DesignerProperties.IsInDesignTool;#else //WPFreturnSystem.ComponentModel.DesignerProperties.GetIsInDesignMode(this);#endif}}6. Generating Design Time Data#2
    20. 20. Windows Phone:this.NavigationService.Navigate(new Uri("/MyPage.xaml?parameter="+param.ToString(),UriKind.Relative));this.NavigationService.Navigate(new Uri("MyAssembly;component/MyPage.xaml", UriKind.Relative));Windows Store:this.Frame.Navigate(typeof(MyPage), param);7. Page Navigation
    21. 21. Windows Phone:protected override void OnNavigatedTo(NavigationEventArgs e){string parameter = NavigationContext.QueryString["parameter"];base.OnNavigatedTo(e);}Windows Store:protected override void OnNavigatedTo(NavigationEventArgs e){object parameter = e.Parameter;base.OnNavigatedTo(e);}7. Page Navigation
    22. 22. GridView  LongListSelector8. Controls #2
    23. 23. Windows StoreIf your app has internet access,it MUST have a privacy policy!Windows PhoneIf your app uses the location service,it MUST have an option to disable it!9. Certification Requirements
    24. 24. 10. Where did it go?Phone StoreRoaming Settings ⛔ UI Controls System.Windows Windows.Xaml.UIBehaviors  ⛔Remote debugging USB WiFi/LANDirectWrite, Direct2D ⛔ WritableBitmap.Render  ⛔RadialBrush  ⛔XNADeprecated(use DirectX)⛔(use DirectX)LOB Company Hub APIs  ⛔Binding.StringFormat  ⛔Native JavaScript Apps ⛔(use PhoneGap) Render DirectX to XAML DrawingSurface SurfaceImageSource
    25. 25. ReferencesMSDN MagazineSharing Code between Windows Phone 8and Windows 8 Applicationshttp://esriurl.com/CodeShare1TechEd 2013 SessionBuild It Once For Both: Writing Code andDesigning for Windows 8 and WindowsPhone 8http://esriurl.com/CodeShare2
    26. 26. Questions?Blog (and slides):www.sharpgis.netTwitter:@dotMortenE-mail:mnielsen@esri.com
    27. 27. THANK YOU !

    ×