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

Code before:
                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>
        /// 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()
        {
            IsNavigationCompleted = false;

            if (Source != null)
            {
                /* CoreWebView2.Navigate() will always trigger a navigation even if the content/URI is the same.
                 * Use WebView2.Source to avoid re-navigating to the same content. */
                PreviewBrowser.CoreWebView2.Navigate(Source.ToString());
            }
        }

        private async void PreviewWV2_Loaded(object sender, RoutedEventArgs e)
        {
            try

Review comment (suggestion):
nit: one neat thing you can do is to change the signature of this method to `private void SourcePropertyChanged()`, and make the property callback on line 23
 `new PropertyChangedCallback((d,e) => ((BrowserControl)d).SourcePropertyChanged())`. 

This is a pattern used in the Community Toolkit that we started using in some places in Photos. I personally find it neater as it keeps the callback free of framework logic, and restricts it to domain logic which is easier to understand. We might want to do that everywhere. 

Code after:
                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()
        {
            IsNavigationCompleted = false;

            if (Source != null)
            {
                /* CoreWebView2.Navigate() will always trigger a navigation even if the content/URI is the same.
                 * Use WebView2.Source to avoid re-navigating to the same content. */
                PreviewBrowser.CoreWebView2.Navigate(Source.ToString());
            }
        }

        private void SourcePropertyChanged()
        {
            Navigate();
        }

        private async void PreviewWV2_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {