Windows 运行时类型的 .NET 映射.NET mappings of Windows Runtime types

下表列出了 .NET 在通用 Windows 平台(UWP)类型和 .NET 类型之间进行的映射。The following table lists the mappings that .NET makes between Universal Windows Platform (UWP) types and .NET types. 在用托管代码编写的通用 Windows 应用程序中,Visual Studio IntelliSense 显示 .NET 类型而不是 UWP 类型。In a Universal Windows app written with managed code, Visual Studio IntelliSense shows the .NET type instead of the UWP type. 例如,如果 Windows 运行时方法采用<IVector 字符串>类型的参数,则 IntelliSense 将显示类型为 IList<string>的参数。For example, if a Windows Runtime method takes a parameter of type IVector<string>, then IntelliSense shows a parameter of type IList<string>. 同样,在使用托管代码编写的 Windows 运行时组件中,你可以在成员签名中使用 .NET 类型。Similarly, in a Windows Runtime component written with managed code, you use the .NET type in member signatures. Windows 运行时元数据导出工具(Winmdexp)生成 Windows 运行时组件时,.net 类型将转换为相应的 UWP 类型。When the Windows Runtime Metadata Export Tool (Winmdexp.exe) generates your Windows Runtime Component, the .NET type is translated into the corresponding UWP type.

UWP 和 .NET 中具有相同命名空间名称和类型名称的大多数类型都是结构(或与结构(如枚举)关联的类型。Most of the types that have the same namespace name and type name in both the UWP and .NET are structures (or types associated with structures, such as enumerations). 在 UWP 中,结构除了字段外没有其他成员,并且需要 .NET 隐藏的帮助器类型。In UWP, structures have no members other than fields, and require helper types, which .NET hides. 这些结构的 .NET 版本具有属性和方法,可提供隐藏帮助程序类型的功能。The .NET versions of these structures have properties and methods that provide the functionality of the hidden helper types.

映射到具有相同名称和命名空间的 .NET 类型的 UWP 类型UWP types that map to .NET types with the same name and namespace

在 .NET 程序集中 System.collections.objectmodel.collectionIn .NET assembly System.ObjectModel.dll

命名空间Namespace 类型Type
Windows.UI.Xaml.InputWindows.UI.Xaml.Input ICommandICommand

在 .NET 程序集 WindowsRuntime 中In .NET assembly System.Runtime.WindowsRuntime.dll

命名空间Namespace 类型Type
Windows.FoundationWindows.Foundation Point
Windows.FoundationWindows.Foundation RectRect
Windows.FoundationWindows.Foundation SizeSize
Windows.UIWindows.UI 颜色Color

在 .NET 程序集的 WindowsRuntime 中In .NET assembly System.Runtime.WindowsRuntime.UI.Xaml.dll

命名空间Namespace 类型Type
Windows.UI.XamlWindows.UI.Xaml CornerRadiusCornerRadius
Windows.UI.XamlWindows.UI.Xaml DurationDuration
Windows.UI.XamlWindows.UI.Xaml DurationTypeDurationType
Windows.UI.XamlWindows.UI.Xaml GridLengthGridLength
Windows.UI.XamlWindows.UI.Xaml GridUnitTypeGridUnitType
Windows.UI.XamlWindows.UI.Xaml ThicknessThickness
Windows.UI.Xaml.Controls.PrimitivesWindows.UI.Xaml.Controls.Primitives GeneratorPositionGeneratorPosition
Windows.UI.Xaml.MediaWindows.UI.Xaml.Media MatrixMatrix
Windows.UI.Xaml.Media.AnimationWindows.UI.Xaml.Media.Animation KeyTimeKeyTime
Windows.UI.Xaml.Media.AnimationWindows.UI.Xaml.Media.Animation RepeatBehaviorRepeatBehavior
Windows.UI.Xaml.Media.AnimationWindows.UI.Xaml.Media.Animation RepeatBehaviorTypeRepeatBehaviorType
Windows.UI.Xaml.Media.Media3DWindows.UI.Xaml.Media.Media3D Matrix3DMatrix3D

映射到具有不同名称和/或命名空间的 .NET 类型的 UWP 类型UWP types that map to .NET types with a different name and/or namespace

在 .NET 程序集中 System.collections.objectmodel.collectionIn .NET assembly System.ObjectModel.dll

UWP 类型/命名空间UWP type/namespace .NET 类型/命名空间.NET type/namespace
INotifyCollectionChanged (Windows.UI.Xaml.Interop)INotifyCollectionChanged (Windows.UI.Xaml.Interop) INotifyCollectionChanged (System.Collections.Specialized)INotifyCollectionChanged (System.Collections.Specialized)
NotifyCollectionChangedEventHandler (Windows.UI.Xaml.Interop)NotifyCollectionChangedEventHandler (Windows.UI.Xaml.Interop) NotifyCollectionChangedEventHandler (System.Collections.Specialized)NotifyCollectionChangedEventHandler (System.Collections.Specialized)
NotifyCollectionChangedEventArgs (Windows.UI.Xaml.Interop)NotifyCollectionChangedEventArgs (Windows.UI.Xaml.Interop) NotifyCollectionChangedEventArgs (System.Collections.Specialized)NotifyCollectionChangedEventArgs (System.Collections.Specialized)
NotifyCollectionChangedAction (Windows.UI.Xaml.Interop)NotifyCollectionChangedAction (Windows.UI.Xaml.Interop) NotifyCollectionChangedAction (System.Collections.Specialized)NotifyCollectionChangedAction (System.Collections.Specialized)
INotifyPropertyChanged (Windows.UI.Xaml.Data)INotifyPropertyChanged (Windows.UI.Xaml.Data) INotifyPropertyChanged (System.ComponentModel)INotifyPropertyChanged (System.ComponentModel)
PropertyChangedEventHandler (Windows.UI.Xaml.Data)PropertyChangedEventHandler (Windows.UI.Xaml.Data) PropertyChangedEventHandler (System.ComponentModel)PropertyChangedEventHandler (System.ComponentModel)
PropertyChangedEventArgs (Windows.UI.Xaml.Data)PropertyChangedEventArgs (Windows.UI.Xaml.Data) PropertyChangedEventArgs (System.ComponentModel)PropertyChangedEventArgs (System.ComponentModel)

在 .NET 程序集中In .NET assembly System.Runtime.dll

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

在 .NET 程序集 InteropServices. WindowsRuntime 中In .NET assembly System.Runtime.InteropServices.WindowsRuntime.dll

UWP 类型/命名空间UWP type/namespace .NET 类型/命名空间.NET type/namespace
EventRegistrationToken (Windows.Foundation)EventRegistrationToken (Windows.Foundation) EventRegistrationToken (System.Runtime.InteropServices.WindowsRuntime)EventRegistrationToken (System.Runtime.InteropServices.WindowsRuntime)