Επεξεργασία

Κοινή χρήση μέσω


.NET mappings of Windows Runtime types in UWP apps

This article lists the mappings that .NET makes between Windows Runtime (WinRT) types and .NET types in Universal Windows Platform (UWP) apps written with managed code. In these apps, Visual Studio IntelliSense shows the .NET type instead of the WinRT type. For example, if a WinRT method takes a parameter of type IVector<string>, then IntelliSense shows a parameter of type IList<string>. Similarly, in a Windows Runtime component written with managed code, you use the .NET type in member signatures. When the Windows Runtime Metadata Export Tool (Winmdexp.exe) generates your Windows Runtime component, the .NET type is translated into the corresponding WinRT type.

Most of the types that have the same namespace name and type name in both WinRT and .NET are structures (or types associated with structures, such as enumerations). In WinRT, structures have no members other than fields, and require helper types, which .NET hides. The .NET versions of these structures have properties and methods that provide the functionality of the hidden helper types.

Note

For a list of mappings between WinRT and .NET types in the context of desktop apps that target .NET and use C#/WinRT, see .NET mappings of WinRT types in C#/WinRT.

WinRT types that map to .NET types with the same name and namespace

In .NET assembly System.ObjectModel.dll

Namespace Type
Windows.UI.Xaml.Input ICommand

In .NET assembly System.Runtime.WindowsRuntime.dll

Namespace Type
Windows.Foundation Point
Windows.Foundation Rect
Windows.Foundation Size
Windows.UI Color

In .NET assembly System.Runtime.WindowsRuntime.UI.Xaml.dll

Namespace Type
Windows.UI.Xaml CornerRadius
Windows.UI.Xaml Duration
Windows.UI.Xaml DurationType
Windows.UI.Xaml GridLength
Windows.UI.Xaml GridUnitType
Windows.UI.Xaml Thickness
Windows.UI.Xaml.Controls.Primitives GeneratorPosition
Windows.UI.Xaml.Media Matrix
Windows.UI.Xaml.Media.Animation KeyTime
Windows.UI.Xaml.Media.Animation RepeatBehavior
Windows.UI.Xaml.Media.Animation RepeatBehaviorType
Windows.UI.Xaml.Media.Media3D Matrix3D

WinRT types that map to .NET types with a different name and/or namespace

In .NET assembly System.ObjectModel.dll

WinRT type/namespace .NET type/namespace
INotifyCollectionChanged (Windows.UI.Xaml.Interop) INotifyCollectionChanged (System.Collections.Specialized)
NotifyCollectionChangedEventHandler (Windows.UI.Xaml.Interop) NotifyCollectionChangedEventHandler (System.Collections.Specialized)
NotifyCollectionChangedEventArgs (Windows.UI.Xaml.Interop) NotifyCollectionChangedEventArgs (System.Collections.Specialized)
NotifyCollectionChangedAction (Windows.UI.Xaml.Interop) NotifyCollectionChangedAction (System.Collections.Specialized)
INotifyPropertyChanged (Windows.UI.Xaml.Data) INotifyPropertyChanged (System.ComponentModel)
PropertyChangedEventHandler (Windows.UI.Xaml.Data) PropertyChangedEventHandler (System.ComponentModel)
PropertyChangedEventArgs (Windows.UI.Xaml.Data) PropertyChangedEventArgs (System.ComponentModel)

In .NET assembly System.Runtime.dll

WinRT type/namespace .NET type/namespace
AttributeUsageAttribute (Windows.Foundation.Metadata) AttributeUsageAttribute (System)
AttributeTargets (Windows.Foundation.Metadata) AttributeTargets (System)
DateTime (Windows.Foundation) DateTimeOffset (System)
EventHandler<T> (Windows.Foundation) EventHandler<T> (System)
HResult (Windows.Foundation) Exception (System)
IReference<T> (Windows.Foundation) Nullable<T> (System)
TimeSpan (Windows.Foundation) TimeSpan (System)
Uri (Windows.Foundation) Uri (System)
IClosable (Windows.Foundation) IDisposable (System)
IIterable<T> (Windows.Foundation.Collections) IEnumerable<T> (System.Collections.Generic)
IVector<T> (Windows.Foundation.Collections) IList<T> (System.Collections.Generic)
IVectorView<T> (Windows.Foundation.Collections) IReadOnlyList<T> (System.Collections.Generic)
IMap<K,V> (Windows.Foundation.Collections) IDictionary<TKey,TValue> (System.Collections.Generic)
IMapView<K,V> (Windows.Foundation.Collections) IReadOnlyDictionary<TKey,TValue> (System.Collections.Generic)
IKeyValuePair<K,V> (Windows.Foundation.Collections) KeyValuePair<TKey,TValue> (System.Collections.Generic)
IBindableIterable (Windows.UI.Xaml.Interop) IEnumerable (System.Collections)
IBindableVector (Windows.UI.Xaml.Interop) IList (System.Collections)
TypeName (Windows.UI.Xaml.Interop) Type (System)

In .NET assembly System.Runtime.InteropServices.WindowsRuntime.dll

WinRT type/namespace .NET type/namespace
EventRegistrationToken (Windows.Foundation) EventRegistrationToken (System.Runtime.InteropServices.WindowsRuntime)