Compartilhar via


Porting Windows Phone Silverlight to Windows Runtime 8 for I/O, device, and app model

[This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation]

Note  For info about porting to a Universal Windows Platform (UWP) app for Windows 10, see Porting for I/O, device, and app model.

 

The previous topic was Porting XAML and UI.

Code that integrates with the device itself and its sensors involves input from, and output to, the user. It can also involve processing data. But this code is not generally thought of as either the UI layer or the data layer. This code includes integration with the vibration controller, accelerometer, gyroscope, microphone and speaker (which intersect with speech recognition and synthesis), (geo)location, and input modalities such as touch, mouse, keyboard, and pen.

Camera

Windows Phone Silverlight camera capture code uses the Microsoft.Devices.Camera, Microsoft.Devices.PhotoCamera, or Microsoft.Phone.Tasks.CameraCaptureTask classes. To port that code to the Windows Runtime, you can use the MediaCapture class. There is a code example in the CapturePhotoToStorageFileAsync topic. That method allows you to capture a photo to a storage file, and it requires the Microphone and Webcam capabilities to be set in the app package manifest.

Another option is the CameraCaptureUI class, which is Windows-only, and also requires the Microphone and Webcam capabilities.

Lens apps are not supported for Windows Runtime apps.

Device status

A Windows Phone Silverlight app can use the Microsoft.Phone.Info.DeviceStatus class to get info about the device on which the app is running. While there is no direct Windows Runtime equivalent for the Microsoft.Phone.Info namespace, here are some properties and events that you can use in a Windows Phone Store app in place of calls to members of the DeviceStatus class.

Windows Phone Silverlight Windows Runtime
ApplicationCurrentMemoryUsage property AppMemoryUsage property (phone-only)
ApplicationPeakMemoryUsage property Use the memory profiling tools in Visual Studio and the Windows Phone Developer Power Tools. For more info, see Analyze memory usage and Test and troubleshoot apps with the Windows Phone Developer Power Tools.
DeviceFirmwareVersion property SystemFirmwareVersion property (phone-only)
DeviceHardwareVersion property SystemHardwareVersion property (phone-only)
DeviceManufacturer property SystemManufacturer property
DeviceName property SystemProductName property
DeviceTotalMemory property No equivalent
IsKeyboardDeployed property No equivalent. This property provides information about hardware keyboards, which are not commonly used.
IsKeyboardPresent property No equivalent. This property provides information about hardware keyboards, which are not commonly used.
KeyboardDeployedChanged event No equivalent. This property provides information about hardware keyboards, which are not commonly used.
PowerSource property No equivalent
PowerSourceChanged event Handle the RemainingChargePercentChanged event (phone-only). The event is raised when the value of the RemainingChargePercent property (phone-only) decreases by 1%.

 

Orientation

The Windows Runtime app equivalent of the PhoneApplicationPage.SupportedOrientations and Orientation properties is the InitialRotationPreference element in the app package manifest. Select the Application tab if it isn't already selected and select one or more check boxes under Supported rotations to record your preferences.

You're encouraged, however to design the UI of your Universal Windows app to look great regardless of device orientation and screen size. There's more about that in Form factors and user experience, which is the topic after next.

The next topic is Porting business and data layers.