我有一个要求,我需要从UWP中的xaml WebView中的app data文件夹加载html文件.Html文件也引用另一个文件夹("99/js /")中的不同Js文件.任何有UWP知识的人都会指导我.在此先感谢我使用以下代码,Browser是我的WebView.
var Uri = new Uri("ms-appdata:///Local/Downloads/99/index.html");
Browser.Navigate(Uri);
Run Code Online (Sandbox Code Playgroud)
我在99文件夹中的文件夹结构是:
udapte
我正在尝试在离线加载html文件到WebView没有加载相同的html文件正在加载服务器URL.
我需要在Windows 10 UWP应用程序中的XAML页面上加载数据.为此,我编写了代码来在异步任务函数中调用Web服务,我在页面构造函数中调用它.你能告诉我最好的办法吗?以下是我的代码.
public sealed partial class MyDownloads : Page
{
string result;
public MyDownloads()
{
this.InitializeComponent();
GetDownloads().Wait();
string jsonstring = result;
//code for binding follows
}
private async Task GetDownloads()
{
JsonObject jsonObject = new JsonObject
{
{"StudentID", JsonValue.CreateStringValue(user.Student_Id.ToString()) },
};
string ServiceURI = "http://m.xxx.com/xxxx.svc/GetDownloadedNotes";
HttpClient httpClient = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, ServiceURI);
request.Content = new StringContent(jsonObject.ToString(), Encoding.UTF8, "application/json");
HttpResponseMessage response = await httpClient.SendAsync(request);
string returnString = await response.Content.ReadAsStringAsync();
result = returnString;
}
}
Run Code Online (Sandbox Code Playgroud)