Posts

Showing posts with the label WebView2

Donate

Accessing WebView2 Control And It's properties In A C# Class Library

Image
Team, In a situation wherein you need to access a WebView2 control properties in a class library and that the WebView2 control is added in a WPF project, all you need to do is to reference the Microsoft.Web.WebView2.Wpf.dll and Microsoft.Web.WebView2.Core.dll from the WPF project into the class library. The sample code below is a utility class located in a class library project which has a WebView2 control object that performs navigation to a url that is set from the WPF project. public static class WebBrowserUtility { public static readonly DependencyProperty BindableSourceProperty = DependencyProperty.RegisterAttached( "BindableSource" , typeof ( string ), typeof (WebBrowserUtility), new UIPropertyMetadata( null , BindableSourcePropertyChanged)); public static string GetBindableSource(DependencyObject obj) { return ( string )obj.GetValue(BindableSourcePr

How To Set Overlay On Top Of A WPF WebBrowser Or WebView2 Control

Image
Good day! A common scenario to our projects is to use the Overlay concept that is, show a nearly transparent modal on top of our form. I have been using the code below to create an Overlay using just a Border and a TextBlock but to no avail, it just won't sit right on top of the WebBrowser control. In the picture right next to the Border control snippet, only the input controls are covered by the overlay and ignoring the WebBrowser control. <Border BorderBrush= "Black" BorderThickness= "1" Background= "#80000000" Visibility= "{Binding Path=IsBusy, Converter={StaticResource BoolToVisibilityConverter}}" Grid.RowSpan= "4" Grid.ColumnSpan= "3" > <Grid> <TextBlock TextAlignment= "Center" Margin= "0" TextWrapping= "Wrap" Width= "500" Text= "{Binding Path=OverlayMessage}" HorizontalAlignment= "Center" VerticalAlignment= "

Donate