1 / 27

Charles Petzold www.charlespetzold.com

Silverlight for Windows Phone. Charles Petzold www.charlespetzold.com. Agenda. Windows Phone 7 Silverlight for Windows Phone Your first phone application Deploying to a device Page orientation Screen layout Device information. Windows Phones.

chun
Download Presentation

Charles Petzold www.charlespetzold.com

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Silverlight for Windows Phone Charles Petzold www.charlespetzold.com

  2. Agenda • Windows Phone 7 • Silverlight for Windows Phone • Your first phone application • Deploying to a device • Page orientation • Screen layout • Device information

  3. Windows Phones • Meet or exceed a common hardware specification • Minimum 1 GHz ARM v7 CPU and DirectX9 GPU • Minimum 256 MB RAM and 8 GB flash storage • 480 x 800 screen (480 x 320 coming later) • Capacitive 4-point multi-touch screen • Minimum 5-megapixel camera • Location (Assisted-GPS), accelerometer, compass, light sensor, and proximity sensor • Connectivity support via cellular networks and WiFi • Available from Samsung, HTC, and other OEMs

  4. Windows Phone 7 • Operating system for Windows phones • Clean break from the past (Windows Mobile) • Released in U.S. on November 8, 2010 • "Metro" user interface • Crisp and sexy (icon grids are boring) • Start screen populated with tiles • Hubs that aggregate content (Pictures, Games, etc.) • Built-in browser based on IE7 and IE8 • Apps written in Silverlight or XNA

  5. Documents You Must Have • UI Design and Interaction Guide for WP7 • http://go.microsoft.com/fwlink/?LinkID=183218 • WP7 Application Certification Requirements • http://go.microsoft.com/?linkid=9730558

  6. Silverlight for Windows Phone • Primary development platform for WP7 phones • Based on Silverlight 3, but with some features of 4 • Adds many phone-specific features • Page orientation (portrait or landscape) • Richer touch APIs (Manipulation events) • Sensor and location APIs • Device APIs (e.g., camera) • Launchers and choosers and more • Based on .NET Compact Framework 3.7

  7. Phone Developer Tools • Windows Phone Developer Tools • Visual Studio 2010 Express for Windows Phone • Expression Blend for Windows Phone • Windows Phone Emulator • XNA Game Studio • http://www.microsoft.com/downloads/en/details.aspx?FamilyID=04704acf-a63a-4f97-952c-8b51b34b00ce • Silverlight for Windows Phone Toolkit • http://silverlight.codeplex.com/releases/view/55034

  8. Windows Phone Emulator • Runs phone apps in a VM • Supports multi-touch on PCs with multi-touch screens and OSes that support multi-touch • For best performance, enable hardware-assisted virtualization in your BIOS • http://www.microsoft.com/windows/virtual-pc/support/configure-bios.aspx • For GPU emulation, run dxdiag.exe and make sure DDI version >= 10 and WDDM version >= 1.1 • http://www.andybeaulieu.com/Default.aspx?EntryID=196&tabid=67

  9. Your First Windows Phone Application

  10. Deploying to a Device • Visual Studio supports deploying to the emulator or to a device (phone) • To deploy to a device, you must: • Register and obtain a developer account • http://create.msdn.com/en-us/home/membership • Unlock the device with the Developer Registration Tool • http://msdn.microsoft.com/en-us/library/ff769508(v=vs.92).aspx • Download and install the Zune client • http://www.zune.net/en-US/products/software • Debugger works with code running on a device!

  11. Zune Client • Start the Zune client before deploying to device • Media APIs not available while client is running

  12. WPConnect • First shipped in October 2010 tools update • Enables apps running on phones connected to PCs to access media APIs

  13. Testing on a Device

  14. Page Orientation • Display can rotate when orientation changes • PhoneApplicationPage.SupportedOrientations controls behavior when orientation changes • Portrait – Display does not rotate • Landscape – Display does not rotate • PortraitOrLandscape – Display rotates automatically • PhoneApplicationPage.OrientationChangedevents fire when orientation changes • If SupportedOrientations = "PortraitOrLandscape"

  15. Preventing the Page from Rotating // In MainPage.xaml SupportedOrientations="Portrait"

  16. Rotating the Page // In MainPage.xaml SupportedOrientations="PortraitOrLandscape"

  17. Customizing the Rotated Page // In the page constructor this.OrientationChanged+= new EventHandler<OrientationChangedEventArgs>(OnOrientationChanged); private void OnOrientationChanged(object sender, OrientationChangedEventArgs e) { if ((e.Orientation & PageOrientation.Landscape) != 0) { // TODO: Adjust the page for landscape mode } else // Portrait { // TODO: Adjust the page for portrait mode } }

  18. Page Orientation

  19. Screen Layout • Screen layout includes optional system tray and application bar System tray 32 pixels high in portrait mode 72 pixels high in landscape mode Application bar 72 pixels high in portrait mode 72 pixels high in landscape mode

  20. Hiding the System Tray // In MainPage.xaml <phone:PhoneApplicationPagex:Class="PhoneDemo.MainPage" ... FontFamily="{StaticResourcePhoneFontFamilyNormal}" FontSize="{StaticResourcePhoneFontSizeNormal}" Foreground="{StaticResourcePhoneForegroundBrush}" SupportedOrientations="Portrait" Orientation="Portrait" shell:SystemTray.IsVisible="False"> Hide the system tray

  21. Getting the Absolute Screen Size double width = Application.Current.Host.Content.ActualWidth; double height = Application.Current.Host.Content.ActualHeight;

  22. Getting the Usable Screen Size double width = this.ActualWidth; double height = this.ActualHeight;

  23. Getting Device Information • DeviceExtendedProperties class provides information about host device • Retrieve dictionary-type values with GetValue

  24. DeviceExtendedProperties

  25. Getting Model Information string manufacturer = DeviceExtendedProperties.GetValue ("DeviceManufacturer").ToString(); string name = DeviceExtendedProperties.GetValue ("DeviceName").ToString(); string id = BitConverter.ToString((byte[]) DeviceExtendedProperties.GetValue("DeviceUniqueId"));

  26. Getting Memory Information string total = ((long)DeviceExtendedProperties.GetValue ("DeviceTotalMemory")).ToString("N0") + " bytes"; string current = ((long)DeviceExtendedProperties.GetValue ("ApplicationCurrentMemoryUsage")).ToString("N0") + " bytes"; string peak = ((long)DeviceExtendedProperties.GetValue ("ApplicationPeakMemoryUsage")).ToString("N0") + " bytes";

  27. Questions? Charles Petzold www.charlespetzold.com

More Related