Blazor Maui Hybrid WebView Zoom settings (windows)

Richard Grieveson 1 Reputation point
2022-12-11T07:12:00.243+00:00

Hello

I have a Blazor Maui hybrid app running (WebView). When the app runs (windows platform) the zoom state is 100% (equivalent to Edge or Chrome Zoom settings). The user can change the zoom state using ctrl + mouse wheel. If you change the zoom settings in edge on say Blazor Server the browser remembers the zoom state. In Maui the app does not remember the change in zoom settings so next to you fire it up you are back to 100%.

I want to be able to capture the zoom settings, store it in say Preferences and then re-apply in (say) the BlazorWebViewInitialized event.

I can't find much in the way of zoom properties. Closest I can get is a Boolean that controls whether zooming is allowed by the user (e.WebView.CoreWebView2.Settings.IsZoomControlEnabled).

Anyone know if this is possible?

Thank you

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,596 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,594 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 44,011 Reputation points Microsoft Vendor
    2022-12-12T07:44:42.287+00:00

    Hello,

    I can't find much in the way of zoom properties. Closest I can get is a Boolean that controls whether zooming is allowed by the user (e.WebView.CoreWebView2.Settings.IsZoomControlEnabled).

    On the MAUI Windows platform, BlazorWebView corresponds to the WebView2 control based on WinUI3.

    In general, we can use ZoomFactor Property to control scaling, you can refer to CoreWebView2Controller.ZoomFactor Property.

    However, this API has not yet been exposed to WinUI3 applications. You could keep following this issue: WebView2: Expose more functionality from CoreWebView2Controller #5772.

    This means that it is currently not feasible to listen to zoom events and save or modify zoom value on MAUI.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.