title: Resizing WP8 WebBrowser Height to Fit Content
body: <p>i have webbrowser control where i am displaying the content.</p>
  
  <p>Here is the code : </p>
  
  <pre><code>&lt;Grid MinHeight="80"
                Grid.Row="2"
                Background="Red"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"&gt;
              &lt;phone:WebBrowser Name="webBrowser1"
                                Height="Auto"
                                IsScriptEnabled="True"
                                ScriptNotify="webBrowser1_ScriptNotify"
                                HorizontalAlignment="Stretch" 
                                VerticalAlignment="Stretch"
                                VerticalContentAlignment="Center" 
                                HorizontalContentAlignment="Center" 
                                Foreground="Black" Width="Auto"&gt;&lt;/phone:WebBrowser&gt;
          &lt;/Grid&gt;
  </code></pre>
  
  <p>In .CS file;</p>
  
  <pre><code>   webBrowser1.NavigateToString("&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body bgcolor=#d5e1f3&gt;&lt;p style=font-family:arial&gt;&lt;font size=3&gt;&lt;center&gt;" + content + "&lt;/center&gt;&lt;/font&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;"); 
  </code></pre>
  
  <p>here content is:</p>
  
  <pre><code>  string content = "Which word in the following sentence is the subject?&lt;I&gt;Paris is beautiful during Spring.&lt;/I&gt;Which word in the following sentence is the subject Which word in the following sentence is the subject Which word in the following sentence is the subject";
  </code></pre>
  
  <p>But i have searched for this issue and found many posts but none of them works for me:</p>
  
  <p>1) <a href="https://stackoverflow.com/questions/12394834/vertical-stretch-webbrowser-to-fit-content-inside">Vertical stretch WebBrowser to fit content inside</a></p>
  
  <p>2) <a href="http://dan.clarke.name/2011/05/resizing-wp7-webbrowser-height-to-fit-content/" rel="nofollow noreferrer">http://dan.clarke.name/2011/05/resizing-wp7-webbrowser-height-to-fit-content/</a></p>
  
  <p>3) <a href="http://social.msdn.microsoft.com/Forums/wpapps/en-US/232eb27e-5a40-4725-a1dd-f68379dc76b7/webbrowser-sizing-to-fit-content?forum=wpdevelop" rel="nofollow noreferrer">http://social.msdn.microsoft.com/Forums/wpapps/en-US/232eb27e-5a40-4725-a1dd-f68379dc76b7/webbrowser-sizing-to-fit-content?forum=wpdevelop</a></p>
  
  <p>4) <a href="http://i.nt.ro/how-do-you-resize-a-webbrowser-control-to-fit-on-a-html-element/" rel="nofollow noreferrer">http://i.nt.ro/how-do-you-resize-a-webbrowser-control-to-fit-on-a-html-element/</a></p>
  
  <p>How to solve this issue ?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Ok the complete XAMl:</p>
  
  <pre><code>&lt;phone:PhoneApplicationPage
      x:Class="POCBase.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
      xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      FontFamily="{StaticResource PhoneFontFamilyNormal}"
      FontSize="{StaticResource PhoneFontSizeNormal}"
      Foreground="{StaticResource PhoneForegroundBrush}"
      SupportedOrientations="Portrait" Orientation="Portrait"
      mc:Ignorable="d"
      shell:SystemTray.IsVisible="True"&gt;
  
      &lt;!--LayoutRoot is the root grid where all page content is placed--&gt;
      &lt;Grid x:Name="LayoutRoot" Background="Transparent"&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="Auto"/&gt;
              &lt;RowDefinition Height="Auto"/&gt;
              &lt;RowDefinition Height="Auto"/&gt;
              &lt;RowDefinition Height="Auto"/&gt;
          &lt;/Grid.RowDefinitions&gt;
  
          &lt;!--TitlePanel contains the name of the application and page title--&gt;
          &lt;StackPanel Grid.Row="0" Margin="12,17,0,28"&gt;
              &lt;TextBlock Name="AppName" Text="" Style="{StaticResource PhoneTextNormalStyle}"/&gt;
              &lt;TextBlock Name="PageName" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/&gt;
          &lt;/StackPanel&gt;
  
          &lt;!--ContentPanel - place additional content here--&gt;
          &lt;Grid MinHeight="80" 
                Grid.Row="1"
                Background="Red"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Center"&gt;
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width="0.20*"&gt;&lt;/ColumnDefinition&gt;
                  &lt;ColumnDefinition Width="0.80*"&gt;&lt;/ColumnDefinition&gt;
              &lt;/Grid.ColumnDefinitions&gt;
              &lt;Image Height="60" 
                     Width="60"
                     Grid.Column="0"
                     Margin="0,0,20,0"
                     VerticalAlignment="Center"
                     HorizontalAlignment="Right"&gt;&lt;/Image&gt;
              &lt;TextBlock Text="Addition Rule "
                         Name="Inilinetext"
                         FontSize="32"
                         Grid.Column="1"
                         TextWrapping="Wrap"
                         Padding="10,0,0,0"
                         VerticalAlignment="Center"
                         HorizontalAlignment="Left"
                         TextAlignment="Left"&gt;&lt;/TextBlock&gt;
          &lt;/Grid&gt;
          &lt;Grid MinHeight="80"
                Grid.Row="2"
                Background="Red"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"&gt;
              &lt;phone:WebBrowser Name="webBrowser1"
                                Height="Auto"
                                IsScriptEnabled="True"
                                ScriptNotify="webBrowser1_ScriptNotify"
                                HorizontalAlignment="Stretch" 
                                VerticalAlignment="Stretch"
                                VerticalContentAlignment="Center" 
                                HorizontalContentAlignment="Center" 
                                Foreground="Black" Width="Auto"&gt;&lt;/phone:WebBrowser&gt;
          &lt;/Grid&gt;
  
          &lt;Grid MinHeight="80" 
                Grid.Row="3"
                Background="Red"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"&gt;
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width="0.20*"&gt;&lt;/ColumnDefinition&gt;
                  &lt;ColumnDefinition Width="0.80*"&gt;&lt;/ColumnDefinition&gt;
              &lt;/Grid.ColumnDefinitions&gt;
              &lt;Image Height="60" 
                     Width="60"
                     Grid.Column="0"
                     Margin="0,0,20,0"
                     VerticalAlignment="Center"
                     HorizontalAlignment="Right"&gt;&lt;/Image&gt;
              &lt;TextBlock Text="Addition Rule "
                         FontSize="32"
                         Grid.Column="1"
                         TextWrapping="Wrap"
                         Padding="10,0,0,0"
                         VerticalAlignment="Center"
                         HorizontalAlignment="Left"
                         TextAlignment="Left"&gt;&lt;/TextBlock&gt;
          &lt;/Grid&gt;
      &lt;/Grid&gt;
  
  &lt;/phone:PhoneApplicationPage&gt;
  </code></pre>