DataPackageView Class
DataPackage の読み取り専用バージョン。共用コンテンツを受信するアプリケーションは、コンテンツ取得時にこのオブジェクトを得ます。
構文
属性
- DualApiPartitionAttribute()
- MarshalingBehaviorAttribute(Agile)
- VersionAttribute(NTDDI_WIN8)
メンバー
DataPackageViewクラス には次の種類のメンバーが含まれます:
メソッド
The DataPackageView クラス には次のメソッドがあります。C#、Visual Basic、C++ では、次のもののメソッドも継承しますObject クラス.
| メソッド | 説明 |
|---|---|
| Contains | Checks to see if the DataPackageView contains a specific data format. |
| GetBitmapAsync | Gets the bitmap image contained in the DataPackageView |
| GetDataAsync | Gets the data contained in the DataPackageView. |
| GetHtmlFormatAsync | Gets the HTML stored in the DataPackageView object. |
| GetResourceMapAsync | Gets the data (such as an image) referenced in HTML content. |
| GetRtfAsync | Gets the rich text formatted (RTF) content contained in a DataPackageView. |
| GetStorageItemsAsync | Gets the files and folders stored in a DataPackageView object. |
| GetTextAsync() | Gets the text in the DataPackageView object. |
| GetTextAsync(String) | Gets the text in the DataPackageView object. |
| GetUriAsync | Gets the URI contained in the DataPackageView. |
| ReportOperationCompleted | Informs the system that your app is finished using the DataPackageView object. Primarily used for Clipboard operations. |
プロパティ
DataPackageViewクラス次のプロパティがあります。
| プロパティ | アクセスの種類 | 説明 |
|---|---|---|
| 読み取り専用 | Returns the formats the DataPackageView contains. | |
| 読み取り専用 | Gets a DataPackagePropertySetView object, which contains a read-only set of properties for the data in the DataPackageView object. | |
| 読み取り専用 | Gets the requested operation (such as copy or move). Primarily used for Clipboard actions. |
注釈
共有操作中に、ソース アプリケーションは共有されているデータを DataPackage オブジェクトに設置し、処理のためオブジェクトをターゲット アプリに送信します。DataPackage クラスには、次の既定の形式をサポートする多くのメソッドが含まれます。text、Rtf、Html、Bitmap、StorageItems。また、カスタム データ形式をサポートするメソッドもあります。これらの形式を使用するには、ソース アプリケーションとターゲット アプリケーションの両方は、カスタム形式が存在することを既に注意している必要があります。
ターゲット アプリケーションは、共有するデータの取得に DataPackageView オブジェクトを使用できます。さらに、これらのアプリは、DataPackageView がサポートするフォーマットを識別する AvailableFormats プロパティ、または特定の形式を照会する Contains メソッドを使用できます。
データをすぐに提供する代わりに DataPackage にデリゲートを割り当てる SetDataProvider を使用するオプションがソース アプリケーションにはあります。このプロセスは、ソース アプリケーションが指定された書式をサポートしていても、ターゲット アプリケーションが要求しない限りはデータを生成する必要がない場合に便利です。 たとえば、ソース アプリケーションは、写真を共有するためのさまざまなイメージ形式をサポートする場合があります。これらの書式を使用して各イメージのコピーを複数作成する代わりに、ソース アプリケーションは、対象のアプリケーションが特定の書式の種類を要求したときに呼び出されるデリゲートを使用できます。
Windows Phone 8
この API は実装されていません。呼び出された場合は、例外をスローします。
例
DataPackageView を使用して、共有されるテキストを取得する方法を次のコードに示します。この例が正しく動作するには、アプリケーションが共有操作に応答して起動したかどうかを検出するコードを追加する必要があります。詳細については、「テキストを受け取る方法」のトピックを参照してください。
var shareOperation = eventObject.detail.shareOperation; if (shareOperation.data.contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.text)) { shareOperation.data.getTextAsync().done(function (text) { // To output the text using this example, // you need a div tag with an id of "output" in your HTML file. document.getElementById("output").innerText = text; }, function (e) { displayError("Error retrieving Text format: " + e); } }); }
要件
|
サポートされている最小のクライアント | Windows 8 [Windows ストア アプリ, デスクトップ アプリ] |
|---|---|
|
サポートされている最小のサーバー | Windows Server 2012 [Windows ストア アプリ, デスクトップ アプリ] |
|
サポートされている最小の電話 | Windows Phone 8 |
|
名前空間 |
|
|
メタデータ |
|
参照
- コンテンツ ターゲット アプリケーション サンプルの共有
- クイック スタート: コンテンツの共有 (JavaScript を使った Windows Store アプリ)
- クイック スタート: コンテンツの共有 (C#/VB/C++ と XAML を使った Windows Store アプリ)
- クイック スタート: 共有コンテンツの受信 (JavaScript を使った Windows Store アプリ)
- クイック スタート: 共有コンテンツの受信 (C#/VB/C++ と XAML を使った Windows Store アプリ)