title: WebBrowser in WPF using MVVM pattern
body: <p>I am trying to open HTML file in WebBrowser window of WPF using MVVM patten. </p>
  
  <p>Note: I have fixed the issues  i was getting. Now this code works as desired.</p>
  
  <h2>ViewHTMLPageView.xaml</h2>
  
  <pre><code> &lt;Window x:Class="MyProject.ViewHTMLPageView"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="clr-namespace:MyProject.Utility"
      Title="HTML Report" Height="454" Width="787"
      &gt;
      &lt;Grid Name="grid1"&gt;
        &lt;WebBrowser local:WebBrowserUtility.BindableSource="{Binding ReportPage}"  /&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <h2>ViewHTMLPageViewModel.cs</h2>
  
  <pre><code> namespace MyProject
   {
     public class ViewHTMLPageViewModel: ViewModelBase
     {
      public ViewHTMLPageView()
      {
           //Testing html page on load 
          _reportPage = "&lt;table border='5'&gt;&lt;tr&gt;&lt;td&gt; This is sample &lt;b&gt; bold &lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;";
          OnPropertyChanged("ReportPage");
      }
  
      private string _reportPage;
      public string ReportPage
      {
          get
          {
              return _reportPage;
          }
  
          set
          {
              if (_reportPage != value)
              {
                  _reportPage = value;
                  OnPropertyChanged("ReportPage");
              }
          }
      }
   }
  </code></pre>
  
  <h2>WebBrowserUtility.cs</h2>
  
  <pre><code> using System;
   using System.Collections.Generic;
   using System.Linq;
   using System.Text;
   using System.Windows.Controls; 
   using System.Windows;
  
   namespace MyProject.Utility
   {
     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(BindableSourceProperty);
      }
  
      public static void SetBindableSource(DependencyObject obj, string value)
      {
          obj.SetValue(BindableSourceProperty, value);
      }
  
      public static void BindableSourcePropertyChanged(DependencyObject o, 
                                                       DependencyPropertyChangedEventArgs e)
      {
          var webBrowser = (WebBrowser)o;
          webBrowser.NavigateToString((string)e.NewValue);
      }
     }
   }
  </code></pre>