title: Content alignment for the menu item in WPF does not work
body: <p>I am trying to align the text on the menu item to center. I have already created the code for template, style to take care of other things. Sadly, content alignment is not working, no matter where I declare it. Clearly, I have added some unnecessary tag somewhere that I can't seem to find. Kindly help me find the problem. Below is the full code used. </p>
  
  <p>XAML markup:</p>
  
  <pre><code>   &lt;Menu x:Name="MenuBar" Height="40" VerticalAlignment="Top" Background="#ffFF7A00" Loaded="MenuBar_Loaded"&gt;
      &lt;MenuItem x:Name="HomeMenuItem" Template="{DynamicResource MenuItemTemplate}" Click="HomeMenuItem_Click" Panel.ZIndex="1" Style="{DynamicResource MenuStyle}" &gt;
          &lt;MenuItem.Header&gt;
              &lt;TextBlock Text="Home" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
          &lt;/MenuItem.Header&gt;
      &lt;/MenuItem&gt;
  </code></pre>
  
  <p>Style</p>
  
  <pre><code>        &lt;Style x:Name="MenuStyle" x:Key="MenuStyle" TargetType="{x:Type MenuItem}"&gt;
          &lt;Setter Property="Foreground" Value="#ffffffff"/&gt;
          &lt;Setter Property="BorderBrush" Value="#ffffffff"/&gt;
          &lt;Setter Property="BorderThickness" Value="0,0,1,0"/&gt;
          &lt;Setter Property="FontSize" Value="16"/&gt;
          &lt;Setter Property="FontFamily" Value="Trebuchet MS"/&gt;
          &lt;Setter Property="Width" Value="150"/&gt;
          &lt;Setter Property="Height" Value="40"/&gt;
          &lt;Setter Property="Background" Value="#FFFF7A00"/&gt;
          &lt;Setter Property="Focusable" Value="True"/&gt;
          &lt;Setter Property="IsTabStop" Value="True"/&gt;
          &lt;Style.Triggers&gt;
              &lt;Trigger Property="IsMouseOver" Value="True"&gt;
                  &lt;Setter Property="Foreground" Value="#FF0081A7"/&gt;
              &lt;/Trigger&gt;
              &lt;Trigger Property="IsEnabled" Value="False"&gt;
                  &lt;Setter Property="Visibility" Value="Collapsed"/&gt;
              &lt;/Trigger&gt;
              &lt;Trigger Property="IsPressed" Value="True"&gt;
                  &lt;Setter Property="Background" Value="#FF0081A7"/&gt;
              &lt;/Trigger&gt;
          &lt;/Style.Triggers&gt;
      &lt;/Style&gt;
  </code></pre>
  
  <p>Control template</p>
  
  <pre><code>        &lt;ControlTemplate x:Name="MenuItemTemplate" x:Key="MenuItemTemplate" TargetType="{x:Type MenuItem}"&gt;
          &lt;Border x:Name="templateRoot" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True"&gt;
              &lt;Grid VerticalAlignment="Center"&gt;
                  &lt;Grid.ColumnDefinitions&gt;
                      &lt;ColumnDefinition Width="Auto"/&gt;
                      &lt;ColumnDefinition Width="Auto"/&gt;
                  &lt;/Grid.ColumnDefinitions&gt;
                  &lt;ContentPresenter x:Name="Icon" Content="{TemplateBinding Icon}" ContentSource="Icon" HorizontalAlignment="Center" Height="16" Margin="3" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center" Width="16"/&gt;
                  &lt;Path x:Name="GlyphPanel" Data="F1M10,1.2L4.7,9.1 4.5,9.1 0,5.2 1.3,3.5 4.3,6.1 8.3,0 10,1.2z" Fill="#FF212121" FlowDirection="LeftToRight" Margin="3" Visibility="Collapsed" VerticalAlignment="Center"/&gt;
                  &lt;ContentPresenter ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" Grid.Column="1" ContentStringFormat="{TemplateBinding HeaderStringFormat}" ContentSource="Header" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/&gt;
              &lt;/Grid&gt;
          &lt;/Border&gt;
          &lt;ControlTemplate.Triggers&gt;
              &lt;Trigger Property="Icon" Value="{x:Null}"&gt;
                  &lt;Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/&gt;
              &lt;/Trigger&gt;
              &lt;Trigger Property="IsChecked" Value="True"&gt;
                  &lt;Setter Property="Visibility" TargetName="GlyphPanel" Value="Visible"/&gt;
                  &lt;Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/&gt;
              &lt;/Trigger&gt;
              &lt;Trigger Property="IsHighlighted" Value="True"&gt;
                  &lt;Setter Property="Background" TargetName="templateRoot" Value="#0026A0DA"/&gt;
              &lt;/Trigger&gt;
              &lt;Trigger Property="IsEnabled" Value="False"&gt;
                  &lt;Setter Property="TextElement.Foreground" TargetName="templateRoot" Value="#FF707070"/&gt;
                  &lt;Setter Property="Fill" TargetName="GlyphPanel" Value="#FF707070"/&gt;
              &lt;/Trigger&gt;
          &lt;/ControlTemplate.Triggers&gt;
      &lt;/ControlTemplate&gt;
  </code></pre>
  
  <p>I guess there is a conflicting tag that might be causing this, but I can't seem to find which one. I have already tried using content alignment in hover trigger too, but that didn't work either. </p>