我想在弹出窗口中显示一个简单的WebView,我尝试了此代码,但似乎不起作用。
<Popup x:Name="StandardPopup">
<Border BorderBrush="{StaticResource ApplicationForegroundThemeBrush}"
Background="{StaticResource ApplicationPageBackgroundThemeBrush}"
BorderThickness="2" Width="200" Height="200">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<WebView x:Name="webView1" Source="https://www.bing.com/" HorizontalAlignment="Center"/>
<Button Content="Close" Click="ClosePopupClicked" HorizontalAlignment="Center"/>
</StackPanel>
</Border>
</Popup>
在WebView上没有问题在弹出控制中显示该网站。如果您在Visual Studio中检查视觉树,则问题仅仅是由于WebView的Actuall大小为零。您可以为其设置适当的尺寸,然后您会看到WebView效果很好。
<Popup x:Name="StandardPopup">
<Border BorderBrush="{StaticResource ApplicationForegroundThemeBrush}"
Background="{StaticResource ApplicationPageBackgroundThemeBrush}"
BorderThickness="2" Width="200" Height="200">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<WebView x:Name="webView1" Source="https://www.bing.com/" Width="200" Height="200" HorizontalAlignment="Center" NavigationCompleted="WebView1_NavigationCompleted" />
<Button Content="Close" Click="ClosePopupClicked" HorizontalAlignment="Center" />
</StackPanel>
</Border>
</Popup>