我创建了一个简单的现代UI应用程序,在应用程序加载时显示WebView上localhost站点的内容。当我调试它时,该应用程序工作正常。我已使用Visual Studio远程工具将其部署到另一台计算机上,并按预期工作。
但是,当我在Windows商店中发布它,然后从那里安装应用程序时,该页面为空白。商店中应用程序的名称名为Locked Browser Lite。
我很感激任何建议。
以下是代码:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace App3
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
this.Loaded += PageLoaded;
this.Unloaded += PageUnloaded;
wvMain.HorizontalAlignment = HorizontalAlignment.Stretch;
wvMain.VerticalAlignment = VerticalAlignment.Stretch;
//wvMain.Source = new Uri("http://localhost");
}
private void PageUnloaded(object sender, RoutedEventArgs e)
{
Window.Current.SizeChanged -= Window_SizeChanged;
}
private void PageLoaded(object sender, RoutedEventArgs e)
{
Window.Current.SizeChanged += Window_SizeChanged;
Uri targeturi = new Uri("http://localhost");
wvMain.Navigate(targeturi);
//wvMain.Refresh();
}
private void Window_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
{
wvMain.HorizontalAlignment = HorizontalAlignment.Stretch;
wvMain.VerticalAlignment = VerticalAlignment.Stretch;
}
private void btnReload_Click(object sender, RoutedEventArgs e)
{
PageLoaded(sender, e);
}
}
}
答案 0 :(得分:0)
什么是'localhost'?
我尝试了你的应用程序,是的,它是空白的应用程序..因为你请求的网址,你请求你的应用程序导航到本地主机,而我的机器上没有本地服务器!
如果您有一些自定义HTML页面向用户显示,请尝试将其作为HTML文件脱机使用,并使用webview.NavigateToString(从文件中读取html)..