是否可以在 UWP 的 Popup 中显示 WebView?

Is it possible to display a WebView inside a Popup in UWP?

我想显示一个简单的 WebView inside a 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>

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>