繁体   English   中英

是否可以在UWP的弹出窗口中显示WebView?

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

我想在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>

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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM