Upravit

Sdílet prostřednictvím


Windows Phone Silverlight to UWP API mappings

This topic provides a comprehensive mapping of Windows Phone Silverlight APIs to their Universal Windows Platform (UWP) equivalents. There is generally not a one-to-one mapping of functionality, though: either platform may have more or less functionality than its counterpart in a namespace or class.

The mapping table will help you when you're working in a UWP project and you're re-using source code from a Windows Phone Silverlight project. There are differences in the names of namespaces and classes (including UI controls) between the two platforms. In many cases, it's as easy as changing a namespace name and then your code will compile. Sometimes, a class or API name has changed as well as the namespace name. Other times, the mapping takes a bit more work, and in rare cases requires a change in approach.

**How to use the table:  ** First, search for the name of the class you're using. Classes are listed whenever the mapping is more complicated than simply changing the namespace name. If your class is not listed, then the mapping is just a namespace change. So, find your class's namespace name and you'll find the equivalent UWP namespace name. Your class will be in that namespace. If your namespace is not listed, then its name has not changed.

Note  Windows 10 supports much more of the .NET Framework than a Windows Phone Store app does. For example, Windows 10 has several System.ServiceModel.* namespaces as well as System.Net, System.Net.NetworkInformation, and System.Net.Sockets. Also, in a Windows 10 app, you will benefit from .NET Native, which an ahead-of-time compilation technology that converts MSIL into natively-runnable machine code. .NET Native apps start faster, use less memory, and use less battery than their MSIL counterparts.

Windows Phone Silverlight Windows Runtime
Advertising
Microsoft.Advertising.Mobile.UI.AdControl class AdControl class
Alarms, reminders, and background agents
Microsoft.Phone.BackgroundAgent class BackgroundTaskBuilder class
Microsoft.Phone.Scheduler namespace Windows.ApplicationModel.Background namespace
Microsoft.Phone.Scheduler.Alarm class BackgroundTaskBuilder and ToastNotificationManager classes
Microsoft.Phone.Scheduler.PeriodicTask, ScheduledAction, ScheduledActionService, ScheduledTask , ScheduledTaskAgent classes BackgroundTaskBuilder class
Microsoft.Phone.Scheduler.Reminder class BackgroundTaskBuilder and ToastNotificationManager classes
Microsoft.Phone.PictureDecoder class BitmapDecoder class
Microsoft.Phone.BackgroundAudio namespace Windows.Media.Playback namespace
Microsoft.Phone.BackgroundTransfer namespace Windows.Networking.BackgroundTransfer namespace
App model and environment
System.AppDomain class No direct equivalent. See Application, CoreApplication, classes
System.Environment class No direct equivalent
System.ComponentModel.Annotations class No direct equivalent
System.ComponentModel.BackgroundWorker class ThreadPool class
System.ComponentModel.DesignerProperties class DesignMode class
System.Threading.Thread, System.Threading.ThreadPool classes ThreadPool class
(ST = System.Threading)
ST.Thread.MemoryBarrier method
(ST = System.Threading)
ST.Interlocked.MemoryBarrier method
(ST = System.Threading)
ST.Thread.ManagedThreadId property
(S = System)
S.Environment.ManagedThreadId property
System.Threading.Timer class ThreadPoolTimer class
(SWT = System.Windows.Threading)
SWT.Dispatcher class
CoreDispatcher class
(SWT = System.Windows.Threading)
SWT.DispatcherTimer class
DispatcherTimer class
Blend for Visual Studio
(MEDC = Microsoft.Expression.Drawing.Core)
MEDC.GeometryHelper class
No direct equivalent
Microsoft.Expression.Interactivity namespace Microsoft.Xaml.Interactivity namespace
Microsoft.Expression.Interactivity.Core namespace Microsoft.Xaml.Interactions.Core namespace
(MEIC = Microsoft.Expression.Interactivity.Core)
MEIC.ExtendedVisualStateManager class
No direct equivalent
Microsoft.Expression.Interactivity.Input namespace No direct equivalent
Microsoft.Expression.Interactivity.Media namespace Microsoft.Xaml.Interactions.Media namespace
Microsoft.Expression.Shapes namespace No direct equivalent
(MI = Microsoft.Internal)
MI.IManagedFrameworkInternalHelper interface
No direct equivalent
Contact and calendar data
Microsoft.Phone.UserData namespace Windows.ApplicationModel.Contacts, Windows.ApplicationModel.Appointments namespaces
(MPU = Microsoft.Phone.UserData)
MPU.Account, ContactAddress, ContactCompanyInformation, ContactEmailAddress, ContactPhoneNumber classes
Contact class
(MPU = Microsoft.Phone.UserData)
MPU.Appointments class
AppointmentCalendar class
(MPU = Microsoft.Phone.UserData)
MPU.Contacts class
ContactStore class
Controls and UI infrastructure
ControlTiltEffect.TiltEffect class Animations from the Windows Runtime animation library are built into the default Styles of the common controls. See Animation.
Microsoft.Phone.Controls namespace Windows.UI.Xaml.Controls namespace
(MPC = Microsoft.Phone.Controls)
MPC.ContextMenu class
PopupMenu class
(MPC = Microsoft.Phone.Controls)
MPC.DatePickerPage class
DatePickerFlyout class
(MPC = Microsoft.Phone.Controls)
MPC.GestureListener class
GestureRecognizer class
(MPC = Microsoft.Phone.Controls)
MPC.LongListSelector class
SemanticZoom class
(MPC = Microsoft.Phone.Controls)
MPC.ObscuredEventArgs class
SystemProtection, WindowActivatedEventArgs classes
(MPC = Microsoft.Phone.Controls)
MPC.Panorama class
Hub class
(MPC = Microsoft.Phone.Controls)
MPC.PhoneApplicationFrame,
(SWN = System.Windows.Navigation)
SWN.NavigationService classes
Frame class
(MPC = Microsoft.Phone.Controls)
MPC.PhoneApplicationPage class
Page class
(MPC = Microsoft.Phone.Controls)
MPC.TiltEffect class
PointerDownThemeAnimation class
(MPC = Microsoft.Phone.Controls)
MPC.TimePickerPage class
TimePickerFlyout class
(MPC = Microsoft.Phone.Controls)
MPC.WebBrowser class
WebView class
(MPC = Microsoft.Phone.Controls)
MPC.WebBrowserExtensions class
No direct equivalent
(MPC = Microsoft.Phone.Controls)
MPC.WrapPanel class
No direct equivalent for general layout purposes. ItemsWrapGrid and WrapGrid can be used in the items panel template of an items control.
(MPD = Microsoft.Phone.Data)
MPD.Linq namespace
No direct equivalent
(MPD = Microsoft.Phone.Data)
MPD.Linq.Mapping namespace
No direct equivalent
Microsoft.Phone.Globalization namespace No direct equivalent
(MPI = Microsoft.Phone.Info)
MPI.DeviceExtendedProperties, DeviceStatus classes
EasClientDeviceInformation, MemoryManager classes. For more details, see Device status.
(MPI = Microsoft.Phone.Info)
MPI.MediaCapabilities class
No direct equivalent
(MPI = Microsoft.Phone.Info)
MPI.UserExtendedProperties class
AdvertisingManager class
System.Windows namespace Windows.UI.Xaml namespace
System.Windows.Automation namespace Windows.UI.Xaml.Automation namespace
System.Windows.Controls, System.Windows.Input namespaces Windows.UI.Core, Windows.UI.Input, Windows.UI.Xaml.Controls namespaces
System.Windows.Controls.DrawingSurface, DrawingSurfaceBackgroundGrid classes SwapChainPanel class
System.Windows.Controls.RichTextBox class RichEditBox class
System.Windows.Controls.WrapPanel class No direct equivalent for general layout purposes. ItemsWrapGrid and WrapGrid can be used in the items panel template of an items control.
System.Windows.Controls.Primitives namespace Windows.UI.Xaml.Controls.Primitives namespace
System.Windows.Controls.Shapes namespace Windows.UI.Xaml.Controls.Shapes namespace
System.Windows.Data namespace Windows.UI.Xaml.Data namespace
System.Windows.Documents namespace Windows.UI.Xaml.Documents namespace
System.Windows.Ink namespace No direct equivalent
System.Windows.Markup namespace Windows.UI.Xaml.Markup namespace
System.Windows.Navigation namespace Windows.UI.Xaml.Navigation namespace
System.Windows.UIElement.Tap event, EventHandler<GestureEventArgs> delegate Tapped event, TappedEventHandler delegate
Data and services
System.Data.Linq.DataContext class No direct equivalent
System.Data.Linq.Mapping.ColumnAttribute class No direct equivalent
System.Data.Linq.SqlClient.SqlHelpers class No direct equivalent
Devices
Microsoft.Devices, Microsoft.Devices.Sensors namespaces Windows.Devices.Enumeration, Windows.Devices.Enumeration.Pnp, Windows.Devices.Input, Windows.Devices.Sensors namespaces
Microsoft.Devices.Camera, Microsoft.Devices.PhotoCamera classes MediaCapture class. Also, CameraCaptureUI class (Windows only).
Microsoft.Devices.CameraButtons class HardwareButtons class
Microsoft.Devices.CameraVideoBrushExtensions class CaptureElement class
Microsoft.Devices.Environment class No direct equivalent. As a workaround, use conditional compilation and define a custom symbol. Or you may be able to engineer a workaround using the IsAttached property.
Microsoft.Devices.MediaHistory class No direct equivalent
Microsoft.Devices.VibrateController class VibrationDevice class
Microsoft.Devices.Radio.FMRadio class No direct equivalent
Microsoft.Devices.Sensors.Accelerometer, Compass classes In the Windows.Devices.Sensors namespace
Microsoft.Devices.Sensors.Gyroscope class Gyrometer class
Microsoft.Devices.Sensors.Motion class Inclinometer class
Globalization
System.Globalization namespace Windows.Globalization namespace
(ST = System.Threading)
ST.Thread.CurrentCulture property
(SG = System.Globalization)
S.CultureInfo.CurrentCulture property
(ST = System.Threading)
ST.Thread.CurrentUICulture property
(SG = System.Globalization)
S.CultureInfo.CurrentUICulture property
Graphics and animation
Microsoft.Xna.Framework.* namespaces, XNA Framework Class Library, Content Pipeline Class Library No direct equivalent. In general, use Microsoft DirectX with C++. See Developing games and DirectX and XAML interop.
Microsoft.Xna.Framework.Audio.Microphone class MediaCapture class
Microsoft.Xna.Framework.Audio.SoundEffect class MediaElement class
Microsoft.Xna.Framework.GamerServices namespace (WPS = Windows.Phone.System)
WPS.UserProfile.GameServices.Core namespace
Microsoft.Xna.Framework.GamerServices.Guide class No direct equivalent
Microsoft.Xna.Framework.Input.GamePad class HardwareButtons class
Microsoft.Xna.Framework.Input.Touch.TouchPanel class GestureRecognizer class
(MXFM = Microsoft.Xna.Framework.Media)
MXFM.MediaLibrary, MXFM.PhoneExtensions.MediaLibraryExtensions classes
KnownFolders class
Microsoft.Xna.Framework.Media.MediaQueue class SystemMediaTransportControls class
Microsoft.Xna.Framework.Media.Playlist class BackgroundMediaPlayer class
System.Windows.Media namespace Windows.UI.Xaml.Media namespace
System.Windows.Media.RadialGradientBrush class No direct equivalent. See Media and graphics.
System.Windows.Media.Animation namespace Windows.UI.Xaml.Media.Animation namespace
System.Windows.Media.Effects namespace No direct equivalent
System.Windows.Media.Imaging namespace Windows.UI.Xaml.Media.Imaging namespace
System.Windows.Media.Media3D namespace Windows.UI.Xaml.Media.Media3D namespace
System.Windows.Shapes namespace Windows.UI.Xaml.Shapes namespace
Launchers and Choosers
Microsoft.Phone.Tasks.AddressChooserTask, EmailAddressChooserTask, PhoneNumberChooserTask classes ContactPicker class
Microsoft.Phone.Tasks.AddWalletItemTask, AddWalletItemResult classes Windows.ApplicationModel.Wallet namespace
Microsoft.Phone.Tasks.BingMapsDirectionsTask, BingMapsTask classes No direct equivalent
Microsoft.Phone.Tasks.CameraCaptureTask class MediaCapture class. Also, CameraCaptureUI class (Windows only).
Microsoft.Phone.Tasks.MarketplaceDetailTask CurrentApp class (RequestAppPurchaseAsync method)
Microsoft.Phone.Tasks.ConnectionSettingsTask, MarketplaceHubTask, MarketplaceReviewTask, MarketplaceSearchTask, MediaPlayerLauncher, SearchTask, SmsComposeTask, WebBrowserTask classes Launcher class
Microsoft.Phone.Tasks.EmailComposeTask class EmailMessage class
Microsoft.Phone.Tasks.GameInviteTask class No direct equivalent
Microsoft.Phone.Tasks.MapDownloaderTask, MapsDirectionsTask, MapsTask, MapUpdaterTask classes No direct equivalent
Microsoft.Phone.Tasks.PhoneCallTask class PhoneCallManager class
Microsoft.Phone.Tasks.PhotoChooserTask class FileOpenPicker class
Microsoft.Phone.Tasks.SaveAppointmentTask class AppointmentManager class
Microsoft.Phone.Tasks.SaveContactTask, SaveEmailAddressTask, SavePhoneNumberTask classes StoredContact class (Windows Phone only)
Microsoft.Phone.Tasks.SaveRingtoneTask class No direct equivalent
Microsoft.Phone.Tasks.ShareLinkTask, ShareMediaTask, ShareStatusTask classes DataPackage class
Location
System.Device.Location namespace Windows.Devices.Geolocation namespace
System.Device.GeoCoordinateWatcher class Geolocator class
Maps
Microsoft.Phone.Maps namespaces Windows.Services.Maps namespace
Microsoft.Phone.Maps.Controls namespace Windows.UI.Xaml.Controls.Maps namespace
Microsoft.Phone.Maps.Controls.Map class MapControl class
Microsoft.Phone.Maps.Services namespace Windows.Services.Maps namespace
Microsoft.Phone.Maps.Services.GeocodeQuery, ReverseGeocodeQuery classes MapLocationFinder class
System.Device.Location.GeoCoordinate class Geopoint class
Microsoft.Phone.Maps.Services.Route class MapRoute class
Microsoft.Phone.Maps.Services.RouteQuery class MapRouteFinder class
Monetization
Microsoft.Phone.Marketplace namespace Windows.ApplicationModel.Store namespace
Media
Microsoft.Phone.Media namespace MediaElement class
Networking
(MPNN = Microsoft.Phone.Net.NetworkInformation)
MPNN.DeviceNetworkInformation class
Hostname, NetworkInformation classes
(MPNN = Microsoft.Phone.Net.NetworkInformation)
MPNN.NetworkInterface class
NetworkInformation class
(MPNN = Microsoft.Phone.Net.NetworkInformation)
MPNN.NetworkInterfaceInfo class
ConnectionProfile class
(MPNN = Microsoft.Phone.Net.NetworkInformation)
MPNN.NetworkInterfaceList class
NetworkInformation class
(MPNN = Microsoft.Phone.Net.NetworkInformation)
MPNN.SocketExtensions class
No direct equivalent
(MPNN = Microsoft.Phone.Net.NetworkInformation)
MPNN.WebRequestExtensions class
No direct equivalent
Microsoft.Phone.Networking.Voip namespace No direct equivalent
System.Net.CookieCollection class Still supported, but some properties are missing (for example, IsReadOnly)
System.Net.DownloadProgressChangedEventArgs class, and similar classes related to System.Net.WebClient HttpClient class (or System.Net.Http.HttpClient). Derive from System.Net.Http.StreamContent to measure progress.
System.Net.DnsEndPoint, IPAddress classes These classes are still supported, but some properties are missing. Alternatively, port to the HostName class.
System.Net.HttpUtility class HtmlFormatHelper class
System.Net.HttpWebRequest class Partial support, but the recommended, forward-looking alternative is the HttpClient class (or System.Net.Http.HttpClient). These APIs use System.Net.Http.HttpRequestMessage to represent an HTTP request.
System.Net.HttpWebResponse class Still supported, but use Dispose() instead of Close(). But, the recommended, forward-looking alternative is the HttpClient class (or System.Net.Http.HttpClient). These APIs use System.Net.Http.HttpResponseMessage to represent an HTTP response.
(SNN = System.Net.NetworkInformation)
SNN.NetworkChange class
Still supported, except for the constructor.
System.Net.OpenReadCompletedEventArgs class, and similar classes related to System.Net.WebClient HttpClient class (or System.Net.Http.HttpClient)
System.Net.Sockets.Socket class Still supported, but use Dispose() instead of Close(). Alternatively, port to theStreamSocket class.
System.Net.Sockets.SocketException class Still supported, but use the SocketErrorCode property instead of ErrorCode.
System.Net.Sockets.UdpAnySourceMulticastClient, UdpSingleSourceMulticastClient classes DatagramSocket class
System.Net.UploadProgressChangedEventArgs class, and similar classes related to System.Net.WebClient HttpClient class (or System.Net.Http.HttpClient)
System.Net.WebClient class HttpClient class (or System.Net.Http.HttpClient)
System.Net.WebRequest class Partial support (a different set of properties), but the recommended, forward-looking alternative is the HttpClient class (or System.Net.Http.HttpClient). These APIs use System.Net.Http.HttpRequestMessage to represent an HTTP request.
System.Net.WebResponse class Still supported, but use Dispose() instead of Close(). But, the recommended, forward-looking alternative is the HttpClient class (or System.Net.Http.HttpClient). These APIs use System.Net.Http.HttpResponseMessage to represent an HTTP response.
(SN = System.Net)
SN.WriteStreamClosedEventArgs class
HttpClient class (or System.Net.Http.HttpClient)
(SN = System.Net)
SN.WriteStreamClosedEventHandler class
HttpClient class (or System.Net.Http.HttpClient)
System.UriFormatException class System.FormatException class
Notifications
MPN = Microsoft.Phone.Notification namespace Windows.UI.Notifications, Windows.Networking.PushNotifications namespaces
MPN = Microsoft.Phone.Notification
MPN.HttpNotification class
TileNotification class
MPN = Microsoft.Phone.Notification
MPN.HttpNotificationChannel class
PushNotificationChannel class
Programming
System namespace Windows.Foundation namespace
System.Diagnostics.StackFrame, StackTrace classes No direct equivalent
System.Diagnostics namespace Windows.Foundation.Diagnostics namespace
System.ICloneable interface A custom method that returns the appropriate type.
System.Reflection.Emit.ILGenerator class No direct equivalent
Reactive Extensions
Microsoft.Phone.Reactive namespace No direct equivalent
Reflection
System.Type class System.Reflection.TypeInfo class. See Reflection in the .NET Framework for UWP apps.
Resources
System.Resources.ResourceManager class (WA = Windows.ApplicationModel)
WA.Resources.Core and WA.Resources namespaces, ResourceManager class. See Creating and retrieving resources in Windows Runtime apps.
Secure Element
(MPS = Microsoft.Phone.SecureElement)
MPS.SecureElementChannel, MPS.SecureElementSession classes
SmartCardConnection class
(MPS = Microsoft.Phone.SecureElement)
MPS.SecureElementReader class
SmartCardReader class
Security
(SSC = System.Security.Cryptography)
SSC.Aes, SSC.RSA classes
CryptographicEngine class
(SSC = System.Security.Cryptography)
SSC.HMACSHA256, SSC.SHA256 classes
HashAlgorithmProvider class
(SSC = System.Security.Cryptography)
SSC.ProtectedData class
DataProtectionProvider class
(SSC = System.Security.Cryptography)
SSC.RandomNumberGenerator class
CryptographicBuffer class
(SSC = System.Security.Cryptography)
SSC.X509Certificates.X509Certificate class
CertificateEnrollmentManager class
Shell
(MPSh = Microsoft.Phone.Shell)
MPSh.ApplicationBar class
CommandBar class
(MPSh = Microsoft.Phone.Shell)
MPSh.ApplicationBarIconButton class
AppBarButton class (when used inside the PrimaryCommands property)
(MPSh = Microsoft.Phone.Shell)
MPSh.ApplicationBarMenuItem class
AppBarButton class (when used inside the SecondaryCommands property)
(MPSh = Microsoft.Phone.Shell)
MPSh.CycleTileData, MPSh.FlipTileData, MPSh.IconicTileData, MPSh.ShellTileData, MPSh.StandardTileData classes
TileTemplateType class
(MPSh = Microsoft.Phone.Shell)
MPSh.PhoneApplicationService class
CoreApplication, DisplayRequest classes
(MPSh = Microsoft.Phone.Shell)
MPSh.ProgressIndicator class
StatusBarProgressIndicator class
(MPSh = Microsoft.Phone.Shell)
MPSh.ShellTile class
SecondaryTile class
(MPSh = Microsoft.Phone.Shell)
MPSh.ShellTileSchedule class
TileUpdater class
(MPSh = Microsoft.Phone.Shell)
MPSh.ShellToast class
ToastNotificationManager class
(MPSh = Microsoft.Phone.Shell)
MPSh.SystemTray class
StatusBar class
Storage and I/O
Microsoft.Phone.Storage.ExternalStorage, ExternalStorageDevice, ExternalStorageFile, ExternalStorageFolder classes KnownFolders class
System.IO namespace Windows.Storage, Windows.Storage.Streams namespaces
System.IO.Directory class StorageFolder class
System.IO.File class StorageFile and PathIO classes
(SII = System.IO.IsolatedStorage)
SII.IsolatedStorageFile class
ApplicationData.LocalFolder property
(SII = System.IO.IsolatedStorage)
SII.IsolatedStorageSettings class
ApplicationData.LocalSettings property
System.IO.Stream class Still supported, but use ReadAsync() and WriteAsync() instead of BeginRead()/EndRead() and BeginWrite()/EndWrite().
Wallet
Microsoft.Phone.Wallet namespace Windows.ApplicationModel.Wallet namespace
Xml
(SX = System.Xml) SX.XmlConvert.ToDateTime method
(SX = System.Xml) SX.XmlConvert.ToDateTimeOffset method

The next topic is Porting the project.