【问题标题】:Is it possible to display a WebView inside a Popup in UWP?是否可以在 UWP 的弹出窗口中显示 WebView?
【发布时间】:2019-12-12 01:32:30
【问题描述】:

我想在Popup 中显示一个简单的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>

【问题讨论】:

    标签: c# xaml webview uwp popup


    【解决方案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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-17
      • 1970-01-01
      相关资源
      最近更新 更多