我的通用Windows应用需要使用Webview控件加载HTML文件。我尝试了以下在这个问题中给出的解决方案,但是无法使其工作。
在WebView Metro Style应用中加载本地HTML文件
现在我的代码如下所示,它会报错:
错误CS4036 'IAsyncOperation'不包含定义为'GetAwaiter'的内容,也没有接受类型为'IAsyncOperation'的第一个参数的扩展方法'GetAwaiter'(您是否缺少了对'System'的使用指令?)ReaderX c:\ users \ sumod \ documents \ visual studio 2015 \ Projects \ ReaderX \ ReaderX \ Views \ TextView.xaml.cs 28
这是我的代码:
namespace ReaderX.Views
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class TextView : Page
{
private NavPoints point;
public TextView()
{
this.InitializeComponent();
}
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
point = (NavPoints)e.Parameter;
StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
StorageFile sampleFile = await storageFolder.GetFileAsync("sample.txt");
var html = await Windows.Storage.FileIO.ReadTextAsync(sampleFile);
HTMLViewer.NavigateToString(html);
}
}
}
有没有其他方法可以做到这一点?