简体   繁体   中英

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

I want to display a simple WebView inside a Popup , I tried this code but doesn't seem to be working.

<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>

There's no problems on WebView for showing the website in Popup control. If you check the visual tree in the visual studio, the issue was just due to the WebView's actuall size is zero. You could set a appropriate size for it, then you will see the WebView works well.

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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