Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Top 10 Things I've Learned About Building W...

Michael Crump
September 06, 2013

The Top 10 Things I've Learned About Building Windows Store Apps as a Silverlight Developer

This session will help existing Silverlight developers get over the hump of building Windows 8 Store apps using XAML/C#. I have built both Silverlight and Windows 8 apps and share 10 things that I’ve found every Silverlight developer should know before starting their first XAML/C# Windows Store App.

Michael Crump

September 06, 2013
Tweet

More Decks by Michael Crump

Other Decks in Technology

Transcript

  1. The Top 10 Things I’ve Learned About Building Windows Store

    Apps as a Silverlight Developer Michael Crump | Telerik | @mbcrump
  2. Introduction Michael Crump Microsoft MVP, Pluralsight & MSDN Author </XAML>,

    Telerik • @mbcrump • http://michaelcrump.net • http://blogs.telerik.com/michaelcrump • http://linkedin.com/in/mbcrump
  3. #1: Starting with the Fundamentals • Bullet 1 • Bullet

    2 • Bullet 3 • Bullet 4 • Bullet 5 • Bullet 6
  4. Fundamentals Silverlight • Hosted inside a web browser via plug-in.

    • SL Apps can run on Windows/Mac even Linux. • You primarily use C#/VB and XAML to develop applications. • XNA – (partial support) Available in SL5. • Uses .NET Framework 2.0-4.5 • Can use any version of Visual Studio to develop for it. • Built primary for mouse/keyboard input. Windows Store App • Runs on top of WinRT inside Windows 8. • Windows Store Applications can only run in Windows 8. • You can use C#/VB/C++/XAML or HTML5/JS/CSS3. • XNA removed. Direct3D available in C++ apps. • Uses .NET Framework 4.5. • Can only develop for it using VS2012 or VS2013 Preview and Windows 8. • Built primary for touch input. (No Chrome)
  5. Silverlight User Request Webpage HTML Page <object> tag loads plug-in

    Plug-in downloads XAP file and reads manifest Create instance of Application Class Fire Application Start up Event Completed page rendering.
  6. Windows Store App Running App Suspended App suspending Terminated App

    Low Memory Code gets to run No code runs App not running resuming User Launches App Splash screen
  7. #3: XML Namespaces You only declare the namespace (never the

    assembly) and you should use "using" instead of "clr-namespace"
  8. #3: XML Namespaces Silverlight <UserControl x:Class="DiggSample.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Digg="clr-namespace:DiggSample"> Windows

    Store App <UserControl x:Class="DiggSample.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Digg="using:DiggSample">
  9. #3: Code Namespaces (continued…) The majority of changes occur in

    the UI related classes. System.Windows -> Windows.UI.Xaml
  10. #3: Code Namespaces cont. Silverlight using System.Windows; using System.Windows.Controls; using

    System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; Windows Store using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Documents; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media.Imaging; using Windows.UI.Xaml.Navigation; using Windows.UI.Xaml.Shapes;
  11. #4: Making WebRequest • WebClient has been removed from WinRT.

    Instead, you can now use HttpClient or WinJS.xhr. • WebRequest makes use of async, await and Tasks<T>. • Callbacks such as IAsyncResult will need to be re-written.
  12. Asynchronous Demystified async avoids the bottleneck of your application being

    executed line by line. • our program can continue to execute. • The "async" keyword enables the "await" keyword in that method. await operator is applied to a task to suspend execution of the method until the task is complete. Tasks<T> represents an asynchronous operation that can return a value.
  13. File I/O Silverlight • IsolatedStorage – Can do anything. •

    Read/Write a file to Documents Folder, etc. via Open/SaveFileDialog or by using Elevated Trust (SL4). • Read/Write a file to the local HDD possible via Open/SaveFileDialog or Full Trust (SL5) will not require user intervention. Windows Store • IsolatedStorage – Can do anything. • Read/Write a file to Documents folder, etc. if you indicate it in the application manifest or use File and Folder Picker API. • Read/Write a file to the local HDD possible via FilePicker only!
  14. Silverlight <navigation:Frame x:Name="ContentFrame" Style="{StaticResource ContentFrameStyle}" Source="/Home" Navigated="ContentFrame_Navigated" NavigationFailed="ContentFrame_NavigationFailed"> <navigation:Frame.UriMapper> <uriMapper:UriMapper>

    <uriMapper:UriMapping Uri="" MappedUri="/Views/Home.xaml"/> <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/> </uriMapper:UriMapper> </navigation:Frame.UriMapper> </navigation:Frame> this.NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));
  15. Windows Store Apps private void HyperlinkButton_Click_1(object sender, RoutedEventArgs e) {

    this.Frame.Navigate(typeof(BasicPage2)); } <HyperlinkButton Content="Click to go to page 2" Click="HyperlinkButton_Click_1"/>
  16. Silverlight Controls - MIA Calendar ChildWindow DataGrid DataPager DescriptionViewer MultiScaleImage

    OpenFileDialog RichTextBox SaveFileDialog TabControl TabItem TreeView Validation WebBrowser
  17. Silverlight Animations Animation Easing allows you to apply built in

    animation functions to your Silverlight controls. The result is a variety of animation effects that make your controls move in a more realistic way.
  18. Windows Store Animations Animation Library – FREE! http://bit.ly/IO3oVR • Theme

    Transitions – animate loading, unloading or changing location on the screen. • Theme Animations – build to run on user interaction and you must trigger them. You can create custom animations as well.
  19. Charms Charms are a way of preparing Windows 8 for

    an ultimate integration with natural user interface (NUI) technology, which allows you to have everything at your fingertips without going through a whole lot of effort.
  20. Contracts • Windows Store apps use contracts and extensions to

    declare the interactions that they support with other apps and with Windows. • Search contracts opens up your application to intregrate with Windows search. • Share contract allows your app to share content with other apps. • Many others exist and can be found at http://bit.ly/K7hd2B.
  21. Windows Store Sell your application in the Windows Store. •

    Designed for Discovery. • Reach – Global (231 markets) • Enterprise • Flexible business model (free, paid or trial) • Microsoft AD SDK available.
  22. Windows Store • Registration Fee is $49 USD ($99 for

    Companies) • Share up to 80% of the revenue generated from app sales.
  23. Recap 1. Starting with the Fundamentals – A,B,C’s 2. Application

    Lifecycle 3. XML/Code Namespaces 4. Making WebRequest - Async 5. Storage – Files and Isolated Storage 6. Navigation – No more URI 7. Controls – New ones Added 8. Animations – Baked into WinRT 9. Freebies – Charms (Searching and Sharing) 10.Monetizing – With the Microsoft Store
  24. Resources • Main starting point: http://dev.windows.com/ • Silverlight 5 vs.WinRT

    comparison by namespace - http://bit.ly/I4eWTt • See my article in Visual Studio Magazine where I ported a SL2 app to a Windows Store App. http://bit.ly/x2YEI4 • Telerik RadControls for Windows Store Apps – http://www.telerik.com
  25. Thank you! Michael Crump | Telerik • @mbcrump • http://michaelcrump.net

    • http://blogs.telerik.com/michaelcrump • http://linkedin.com/in/mbcrump