UWP:DataPackageView 错误

UWP: DataPackageView Bug

Clipboard Class state, that the getContent() Method returns a DataPackageView 对象的文档。到目前为止一切顺利。

以下作品:

var containsString = Windows.ApplicationModel.DataTransfer.Clipboard.getContent().contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.text)

containsString 等于真。

以下无效:

var text = Windows.ApplicationModel.DataTransfer.Clipboard.getContent().getTextAsync();
var text = Windows.ApplicationModel.DataTransfer.Clipboard.getContent().getTextAsync(Windows.ApplicationModel.DataTransfer.StandardDataFormats.text);
var text = Windows.ApplicationModel.DataTransfer.Clipboard.getContent().getHtmlFormatAsync();
var text = Windows.ApplicationModel.DataTransfer.Clipboard.getContent().getDataAsync(Windows.ApplicationModel.DataTransfer.StandardDataFormats.text);

DataPackageView 的上述链接文档中列出了每个方法,在检查 contains(...) 后都返回一个空对象。

这也不行:

var results = Windows.ApplicationModel.DataTransfer.Clipboard.getContent().requestAccessAsync();
var results = Windows.ApplicationModel.DataTransfer.Clipboard.getContent().requestAccessAsync(Windows.ApplicationModel.DataTransfer.StandardDataFormats.text);
var results = Windows.ApplicationModel.DataTransfer.Clipboard.getContent().unlockAndAssumeEnterpriseIdentity();

... 什么都不返回。

是因为这些方法是异步的吗?我需要暂停吗?

我真的什么都试过了。我做错了什么,或者这是 getContent() 方法或 DataPackageView 的错误?

在第一个示例中,您没有调用异步方法。在所有其他情况下,您都会这样做。我这里没有 visual studio,所以无法尝试,但它应该像这样:

Windows.ApplicationModel.DataTransfer.Clipboard.getContent().getTextAsync().then(function(result){
// result should be the text you are expecting
});