次の記事は、.NET がマネージド コードで記述されたユニバーサル Windows プラットフォーム (UWP) アプリで Windows ランタイム (WinRT) 型と .NET 型の間で行うマッピングを示しています。 これらのアプリでは、Visual Studio IntelliSense は、WinRT 型ではなく .NET 型を表示します。 たとえば、WinRT メソッドが IVector<string> 型のパラメーターを受け取る場合、IntelliSense は IList<string> 型のパラメーターを表示します。 同様に、マネージド コードで記述された Windows ランタイム コンポーネントでは、.NET 型をメンバーのシグネチャ内で使います。 Windows ランタイム メタデータ エクスポート ツール (Winmdexp.exe) で Windows ランタイム コンポーネントを生成すると、.NET 型は、対応する WinRT 型に変換されます。
WinRT と .NET の両方で同じ名前空間名と型名を持つ型のほとんどは、構造体 (または列挙型など、構造体に関連付けられている型) です。 WinRT では、構造体にはフィールド以外にメンバーがなく、また、.NET で非表示にするヘルパー型が必要です。 これらの構造体の .NET バージョンには、非表示のヘルパー型の機能を提供するプロパティとメソッドがあります。
Note
.NET を対象とし、C#/WinRT を使用するデスクトップ アプリのコンテキストでの WinRT 型と .NET 型の間のマッピングの一覧については、「C#/WinRT での WinRT 型の.NET マッピング」を参照してください。
同じ名前と名前空間を持つ .NET 型にマップされる WinRT 型
.NET アセンブリの System.ObjectModel.dll
| 名前空間 | Type |
|---|---|
| Windows.UI.Xaml.Input | ICommand |
.NET アセンブリの System.Runtime.WindowsRuntime.dll
| 名前空間 | Type |
|---|---|
| Windows.Foundation | Point |
| Windows.Foundation | 矩形 |
| Windows.Foundation | サイズ |
| Windows.UI | 色 |
.NET アセンブリの System.Runtime.WindowsRuntime.UI.Xaml.dll
| 名前空間 | Type |
|---|---|
| Windows.UI.Xaml | CornerRadius |
| Windows.UI.Xaml | Duration |
| Windows.UI.Xaml | DurationType |
| Windows.UI.Xaml | GridLength |
| Windows.UI.Xaml | GridUnitType |
| Windows.UI.Xaml | 太さ |
| Windows.UI.Xaml.Controls.Primitives | GeneratorPosition |
| Windows.UI.Xaml.Media | マトリックス |
| Windows.UI.Xaml.Media.Animation | KeyTime |
| Windows.UI.Xaml.Media.Animation | RepeatBehavior |
| Windows.UI.Xaml.Media.Animation | RepeatBehaviorType |
| Windows.UI.Xaml.Media.Media3D | Matrix3D |
.NET 型にマップする WinRT 型 (名前や名前空間が異なるもの)
.NET アセンブリの System.ObjectModel.dll
| WinRT の型/名前空間 | .NET 型/名前空間 |
|---|---|
| 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) |
.NET assembly System.Runtime.dll
| WinRT の型/名前空間 | .NET 型/名前空間 |
|---|---|
| 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) |
.NET assembly System.Runtime.InteropServices.WindowsRuntime.dll
| WinRT の型/名前空間 | .NET 型/名前空間 |
|---|---|
| EventRegistrationToken (Windows.Foundation) | EventRegistrationToken (System.Runtime.InteropServices.WindowsRuntime) |