HubSection内的WebView不呈现页面
我在Hub控件的Hub部分中有一个WebView:HubSection内的WebView不呈现页面,webview,windows-store-apps,windows-8.1,Webview,Windows Store Apps,Windows 8.1,我在Hub控件的Hub部分中有一个WebView: <HubSection x:Name="details_section" ...> <!-- ... --> <DataTemplate> <WebView x:Name="webView" VerticalAlignment="Stretch" Margin="0" Height="300" /> </DataTemplate> &
<HubSection x:Name="details_section" ...>
<!-- ... -->
<DataTemplate>
<WebView x:Name="webView" VerticalAlignment="Stretch" Margin="0" Height="300" />
</DataTemplate>
</HubSection>
当然,我进行了调试,以查看该方法是否真正被调用。此外,还将调用LoadCompleted事件
这个问题不是因为我用简单的“hello”测试的HTML代码不好造成的。将HubSection的
HorizontalContentAlignment
和VerticalContentAlignment
设置为Stretch
<HubSection x:Name="details_section"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch">
我通过使用以下扩展解决了此问题: 使用:
相同的代码在集线器之外工作吗?
是的,在集线器之外,WebView能够正确地呈现HTML代码。您是否解决了此问题。我也面临同样的问题issue@W.K.S我已经发布了似乎是一个解决方案(请检查,因为它是很久以前,我不记得):你能解释多一点吗。我不知道如何使用分机。我将WebViewExtension.cs的内容复制到我的项目中的一个文件中,并添加了“xmlns:ns=”using:mylib“xmlns:ext=”using:WSLibrary.Extensions”。这一行中的错误是命名空间WSLibrary.Extensions中的WebViewExtension类(这是基本的C#编程…还请注意xmlns:ns=”using:mylib)“毫无意义……):谢谢。我是c#的新手。我想这就是问题所在
<HubSection x:Name="details_section"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch">
<ns:MyPage
xmlns:ns="using:mylib"
xmlns:ext="using:WSLibrary.Extensions" ...>
<!-- ... -->
<HubSection x:Name="details_section" ...>
<!-- ... -->
<DataTemplate>
<WebView ext:WebViewExtensions.HtmlSource="{Binding MyHtmlString}" ... />
</DataTemplate>
</HubSection>
<!-- ... -->
</ns:MyPage>