Repository: microsoft/PowerToys
File: src/modules/peek/Peek.FilePreviewer/Controls/BrowserControl.xaml.cs (C#)

Code before:

namespace Peek.FilePreviewer.Controls
{
    using System;
    using Microsoft.UI.Xaml;
    using Microsoft.UI.Xaml.Controls;
    using Microsoft.Web.WebView2.Core;
    using Windows.System;

    public sealed partial class BrowserControl : UserControl
    {
        public delegate void NavigationCompletedHandler(WebView2 sender, CoreWebView2NavigationCompletedEventArgs args);

        public event NavigationCompletedHandler NavigationCompleted = (sender, args) => { };

        public static readonly DependencyProperty SourceProperty = DependencyProperty.Register(
                "Source",
                typeof(Uri),
                typeof(BrowserControl),
                new PropertyMetadata(null, new PropertyChangedCallback(SourcePropertyChanged)));

        public static readonly DependencyProperty IsNavigationCompletedProperty = DependencyProperty.Register(
                "IsNavigationCompleted",
                typeof(bool),
                typeof(BrowserControl),
                new PropertyMetadata(null));

        public Uri Source
        {
            get { return (Uri)GetValue(SourceProperty); }
            set { SetValue(SourceProperty, value); }
        }

        public bool IsNavigationCompleted
        {
            get { return (bool)GetValue(IsNavigationCompletedProperty); }
            set { SetValue(IsNavigationCompletedProperty, value); }
        }

        public BrowserControl()
        {
            this.InitializeComponent();
        }

        private static void SourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var browserControl = (BrowserControl)d;
            browserControl.Navigate();
        }

        /// <summary>

Review comment (suggestion):
false would probably be a better default value than null.

Code after:

namespace Peek.FilePreviewer.Controls
{
    using System;
    using Microsoft.UI.Xaml;
    using Microsoft.UI.Xaml.Controls;
    using Microsoft.Web.WebView2.Core;
    using Windows.System;

    public sealed partial class BrowserControl : UserControl
    {
        public delegate void NavigationCompletedHandler(WebView2 sender, CoreWebView2NavigationCompletedEventArgs args);

        public event NavigationCompletedHandler? NavigationCompleted;

        public static readonly DependencyProperty SourceProperty = DependencyProperty.Register(
                nameof(Source),
                typeof(Uri),
                typeof(BrowserControl),
                new PropertyMetadata(null, new PropertyChangedCallback((d, e) => ((BrowserControl)d).SourcePropertyChanged())));

        public static readonly DependencyProperty IsNavigationCompletedProperty = DependencyProperty.Register(
                nameof(IsNavigationCompleted),
                typeof(bool),
                typeof(BrowserControl),
                new PropertyMetadata(false));

        public Uri? Source
        {
            get { return (Uri)GetValue(SourceProperty); }
            set { SetValue(SourceProperty, value); }
        }

        public bool IsNavigationCompleted
        {
            get { return (bool)GetValue(IsNavigationCompletedProperty); }
            set { SetValue(IsNavigationCompletedProperty, value); }
        }

        public BrowserControl()
        {
            this.InitializeComponent();
        }

        /// <summary>
        /// Navigate to the to the <see cref="Uri"/> set in <see cref="Source"/>.
        /// Calling <see cref="Navigate"/> will always trigger a navigation/refresh
        /// even if web target file is the same.
        /// </summary>
        public void Navigate()
        {