我想在WebView中显示一个简单的Popup,我尝试了这段代码,但似乎没有用。
<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>
答案 0 :(得分:1)
WebView在Popup控件中显示网站没有问题。如果您在Visual Studio中检查视觉树,则问题仅仅是由于WebView的实际大小为零。您可以为其设置适当的大小,然后您将看到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>