How to make the WebView2 fit and full the Window (adaptive size effect or full - screen)?

Viewed 657

I tried to set HorizontalAlignment="Stretch" & VerticalAlignment="Stretch" but it was not work.

<Window
    x:Class="Y.Shen12DP.PLCT.WebWidow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:Y.Shen12DP.PLCT"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
    Title="WebWidow"
    Width="800"
    Height="450"
    mc:Ignorable="d">
    <Grid>
        <wv2:WebView2
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            Source="https://www.microsoft.com/" />
    </Grid>
</Window>

enter image description here

Could you tell me how to do it (adaptive size effect or full - screen)?

1 Answers

The code you have will ensure the WebView2 fills the WPF Window. To make it full screen you need to make the WPF Window full screen which is described elsewhere on StackOverflow: Full screen in WPF application. Once the WPF Window is full screen the WebView2 should be full screen as well.

Related