title: C# application- how to display a website inside a xaml form?
body: <p>I am trying to add a web browser to an existing C# application, but, having not used C# in about 6 years, I am quite unfamiliar with how it works.</p>
  
  <p>The GUI for the application has been created using XAML, and I want to use this to add/ embed the web browser within the application, but I'm not sure how to do this.</p>
  
  <p>I have the following script inside my <code>WebBrowser.xaml</code> class:</p>
  
  <pre><code>&lt;Window x:Class="RiviamAgent.WebBrowser"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:local="clr-namespace:RiviamAgent"
      mc:Ignorable="d"
      Title="WebBrowser" Height="500" Width="500"&gt;
  &lt;Window.CommandBindings&gt;
      &lt;CommandBinding Command="New" CanExecute="CommonCommandBinding_CanExecute" /&gt;
      &lt;CommandBinding Command="Open" CanExecute="CommonCommandBinding_CanExecute" /&gt;
      &lt;CommandBinding Command="Save" CanExecute="CommonCommandBinding_CanExecute" /&gt;
  &lt;/Window.CommandBindings&gt;
  &lt;DockPanel&gt;
      &lt;ToolBarTray DockPanel.Dock="Top"&gt;
          &lt;ToolBar Header="File"&gt;
              &lt;Button Command="New" Content="New" ToolBar.OverflowMode="Always" /&gt;
              &lt;Button Command="Open" Content="Open" ToolBar.OverflowMode="Always" /&gt;
              &lt;Button Command="Save" Content="Save" ToolBar.OverflowMode="Always" /&gt;
          &lt;/ToolBar&gt;
          &lt;ToolBar Header="Edit" Margin="5.4,0,-5.4,0"&gt;
              &lt;Button Command="Cut" Content="Cut" ToolBar.OverflowMode="Always" /&gt;
              &lt;Button Command="Copy" Content="Copy" ToolBar.OverflowMode="Always" /&gt;
              &lt;Button Command="Paste" Content="Paste" ToolBar.OverflowMode="Always" /&gt;
          &lt;/ToolBar&gt;
          &lt;ToolBar Margin="9.2,0,-8.2,0"&gt;
              &lt;Button Command="Back" ToolTip="Return to the previous page"/&gt;
              &lt;Image Source="C:\Users\elgan\workspace\browser\riviam_windows\Images\navigateBack.png" Width="20" Height="20" Margin="0,0,0,2.4" /&gt;
          &lt;/ToolBar&gt;
          &lt;ToolBar Margin="16.4,0,-16.2,0" &gt;
              &lt;Button Command="Forward" ToolTip="Proceed to the next page" /&gt;
              &lt;Image Source="C:\Users\elgan\workspace\browser\riviam_windows\Images\navigateForward.png" Width="20" Height="20" /&gt;
          &lt;/ToolBar&gt;
      &lt;/ToolBarTray&gt;
      &lt;TextBox AcceptsReturn="True" /&gt;
      &lt;WebBrowser Name="browser" Navigating="www.google.com"/&gt;
      &lt;TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="12"&gt;
         Web page
      &lt;/TextBlock&gt;
  
  &lt;/DockPanel&gt;
  </code></pre>
  
  <p></p>
  
  <p>and this is currently showing a blank page, with a toolbar at the top containing 'File' &amp; 'Edit' menus, as well as 'Back' and 'Forward' navigation buttons.</p>
  
  <p>I am now trying to display the contents of a website in the rest of the page, but I'm not sure how to do this.</p>
  
  <p>In the last couple of lines that I have written, I am trying to get Google to display in the main area of the GUI (i.e. below the menus and navigation buttons), but at the moment, nothing is being displayed there, other than the text, "Web page".</p>
  
  <p>Can anyone tell me why this is? How can I get the form to display Google or any other website? Thanks in advance.</p>