- 
                Notifications
    
You must be signed in to change notification settings  - Fork 62
 
Closed
Description
The default behavior of WebView2 is that any user applied zoom is only for the current page and is reset on a navigation. I would like to create an experience where the user applied zoom is preserved even on navigation.
I have tried binding the webview's to a property of the viewmodel and updating this property on ZoomFactorChanged Event.
// In MainWindow.xaml
           <wv2:WebView2
                          ZoomFactor="{Binding ZoomFactor}"
                          Name="webView" Source="{Binding CurrentPageUrl}"/>
// In MainWindow.xaml.cs
        public MainWindow()
        {
            InitializeComponent();
            DataContext = viewModel;
            webView.ZoomFactorChanged += WebView_ZoomFactorChanged;
        }
        private void WebView_ZoomFactorChanged(object sender, EventArgs e)
        {
            viewModel.ZoomFactor = webView.ZoomFactor;
        }
However, the changed ZoomFactor is still not applied on navigation to a new page.
On the other hand, when I set the ZoomFactor in viewModel on response to zoom button clicks, the changes to ZoomFactor are correctly applied on navigation. So it seems that the webView is specifically ignoring the ZoomFactor binding when its value is equal to the last ZoomFactor level set by the user.
Metadata
Metadata
Assignees
Labels
No labels