title: Why won't StackPanel put textblock on left and button on right in Silverlight?
body: <p>OK, I give up: what do I have to change to this <strong>StackPanel</strong> below so that it puts the:</p>
  
  <ul>
  <li>text on far left of form </li>
  <li><strong>button on far right of form</strong>.</li>
  </ul>
  
  <p><a href="http://tanguay.info/web/external/stackPanelLeftRight.png" rel="noreferrer">alt text http://tanguay.info/web/external/stackPanelLeftRight.png</a></p>
  
  <pre><code>&lt;UserControl x:Class="TestData333.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      Width="400" Height="300"&gt;
      &lt;Grid x:Name="LayoutRoot" Background="White"&gt;
          &lt;Border CornerRadius="10" Background="Yellow" Padding="20"&gt;
              &lt;StackPanel VerticalAlignment="Top" HorizontalAlignment="Left"&gt;
                  &lt;ScrollViewer Background="Beige" 
                                Height="230"
                                Width="360"&gt;
                      &lt;StackPanel&gt;
                          &lt;TextBlock x:Name="TheContent" 
                             Foreground="Navy"
                             FontSize="14"
                             TextWrapping="Wrap"/&gt;
                      &lt;/StackPanel&gt;
                  &lt;/ScrollViewer&gt;
  
                  &lt;StackPanel Orientation="Horizontal"&gt;
                      &lt;TextBlock x:Name="ProgressIndicator" Text="Ready..."
                                 HorizontalAlignment="Left"/&gt;
                      &lt;Button Content="Load Data"
                          Width="100"
                          HorizontalAlignment="Right"
                          Click="Button_Load"
                          Margin="0 5 0 0"/&gt;
                  &lt;/StackPanel&gt;
  
              &lt;/StackPanel&gt;
          &lt;/Border&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <h1>ANSWER:</h1>
  
  <p>Downloaded <a href="http://silverlight.codeplex.com/Wiki/View.aspx?title=Silverlight%20Toolkit%20Overview%20Part%201" rel="noreferrer">Silverlight 3 toolkit</a> which has DockPanel, installed, referenced System.Windows.Controls, then following XAML:</p>
  
  <pre><code>&lt;UserControl x:Class="TestData333.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
      Width="400" Height="300"&gt;
      &lt;Grid x:Name="LayoutRoot" Background="White"&gt;
          &lt;Border CornerRadius="10" Background="Yellow" Padding="20"&gt;
              &lt;StackPanel VerticalAlignment="Top" HorizontalAlignment="Left"&gt;
                  &lt;ScrollViewer Background="Beige" 
                                Height="230"
                                Width="360"&gt;
                      &lt;StackPanel&gt;
                          &lt;TextBlock x:Name="TheContent" 
                             Foreground="Navy"
                             FontSize="14"
                             TextWrapping="Wrap"/&gt;
                      &lt;/StackPanel&gt;
                  &lt;/ScrollViewer&gt;
  
                  &lt;toolkit:DockPanel Margin="0 5 0 0"&gt;
                      &lt;TextBlock toolkit:DockPanel.Dock="Left" x:Name="ProgressIndicator" Text="Ready..."
                                 FontSize="12"
                                 HorizontalAlignment="Left"/&gt;
                      &lt;Button toolkit:DockPanel.Dock="Right" Content="Load Data"
                          Width="100"
                          HorizontalAlignment="Right"
                          Click="Button_Load"/&gt;
                  &lt;/toolkit:DockPanel&gt;
  
              &lt;/StackPanel&gt;
          &lt;/Border&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p><a href="http://tanguay.info/web/external/silverlightDockPanel.png" rel="noreferrer">alt text http://tanguay.info/web/external/silverlightDockPanel.png</a></p>