title: Right align ToolBarPanel control WPF
body: <p>This is my first time using WPF, I have a usercontrol with a ToolBar, and ToolBarPanels on that ToolBar. My problem is trying to right align the very last ToolBarPanel which contains some buttons.</p>
  
  <p><a href="http://imgur.com/n5v4YCw" rel="nofollow">http://imgur.com/n5v4YCw</a></p>
  
  <p>I have scoured the interwebs and tried solutions (wrap it in a grid, dockpanel, stackpanel) but none have worked.</p>
  
  <p>My XAML is:</p>
  
  <pre><code> &lt;ToolBar 
          HorizontalAlignment="Left" Width="{Binding ActualWidth, ElementName=userControl}"
          VerticalAlignment="Top" 
          Name="ToolBarPanel1" 
          UseLayoutRounding="False"
          ToolBarTray.IsLocked="True"&gt;
  
          &lt;ToolBar.Background&gt;
              &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt;
                  &lt;GradientStop Color="#FF475B7E" Offset="1"/&gt;
                  &lt;GradientStop Color="#FFB9C3D5" Offset="0.427"/&gt;
              &lt;/LinearGradientBrush&gt;
          &lt;/ToolBar.Background&gt;
  
    .........
  
             &lt;ToolBarPanel ToolBar.OverflowMode="AsNeeded" Orientation="Horizontal" HorizontalAlignment="Right" &gt;
  
              &lt;Button
                  Name="btnPrint"
                  Margin="5"
                  HorizontalAlignment="Right"
                  VerticalAlignment="Center"
                  BorderThickness="1" 
                  IsEnabled="{Binding Path=AllowEdit}" 
                  BorderBrush="#FF586A8B" 
                  DockPanel.Dock="Right"
                  Visibility="{Binding Path=ControlVisibility.Print, 
                  Converter={StaticResource BooleanToVisibilityConverter}}"&gt;
                  &lt;Image Source="/component/Images/print-image.png"&gt;&lt;/Image&gt;
                  &lt;Button.ToolTip&gt;
                      &lt;ToolTip&gt;
                          &lt;TextBlock&gt;Print Chart&lt;/TextBlock&gt;
                      &lt;/ToolTip&gt;
                  &lt;/Button.ToolTip&gt;
              &lt;/Button&gt;
  
              &lt;Button
                  Name="btnCopy"                     
                  Margin="5" 
                  HorizontalAlignment="Right" 
                  VerticalAlignment="Center" 
                  BorderThickness="1" 
                  IsEnabled="{Binding Path=AllowEdit}" 
                  BorderBrush="#FF586A8B" 
                  Visibility="{Binding Path=ControlVisibility.Copy, 
                  Converter={StaticResource BooleanToVisibilityConverter}}"&gt;
                  &lt;Image Source="/component/Images/copy-image.png"&gt;&lt;/Image&gt;
                  &lt;Button.ToolTip&gt;
                      &lt;ToolTip&gt;
                          &lt;TextBlock&gt;Copy Chart to Clipboard&lt;/TextBlock&gt;
                      &lt;/ToolTip&gt;
                  &lt;/Button.ToolTip&gt;
              &lt;/Button&gt;
  
              &lt;Button
                  Name="btnInfo" 
                  Margin="5" 
                  HorizontalAlignment="Right" 
                  VerticalAlignment="Center" 
                  BorderThickness="1" 
                  IsEnabled="{Binding Path=AllowEdit}" 
                  BorderBrush="#FF586A8B" 
                  Visibility="{Binding Path=ControlVisibility.Info, 
                  Converter={StaticResource BooleanToVisibilityConverter}}"&gt;
                  &lt;Image Source="/component/Images/help-image.png"&gt;&lt;/Image&gt;
                  &lt;Button.ToolTip&gt;
                      &lt;ToolTip&gt;
                          &lt;TextBlock&gt;Chart Help&lt;/TextBlock&gt;
                      &lt;/ToolTip&gt;
                  &lt;/Button.ToolTip&gt;
              &lt;/Button&gt;
  
          &lt;/ToolBarPanel&gt;
  
      &lt;/ToolBar&gt;
  </code></pre>