Весь код просмотра не отображается, ошибка может быть возвращена к определению меню.
<Menu Grid.Column = "1" Grid.Row = "1">
Вот реализация предложенных вами меню, где меню хорошо центрированыи StackPanel, и Grid.
Контрольный материал Design был заменен кнопкой для проведения теста.
StackPanel
<Window
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"
mc:Ignorable="d"
Title="MainWindow" Width="1137.333"
WindowState="Maximized"
WindowStartupLocation="CenterScreen">
<DockPanel>
<!-- Menu Area -->
<Border VerticalAlignment="Top" DockPanel.Dock="Top" Margin="0,5,0,5">
<!-- Diagram Area -->
<Grid x:Name="DiagramPane" Margin="10,0,10,10">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Menu VerticalAlignment="Top" Grid.Row="0" Height="60" Margin="0,-7,0,0" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="1"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<MenuItem x:Name="OpenSourceView"
Background="Yellow"
HorizontalContentAlignment="Center"
Padding="0"
Height="60" >
<MenuItem.Header>
<StackPanel Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type MenuItem}}}"
VerticalAlignment="Center"
HorizontalAlignment="Center" >
<Button Grid.Column="0" HorizontalAlignment="Center" Height="30" Width="30" Margin="0,0,0,0" IsDefault="True" Command = "{Binding AjoutCommand}" CommandParameter = "null">
<Image Opacity="0.4" HorizontalAlignment="Center" VerticalAlignment="Center" Source="/Images/AddFile.png" Grid.Column="2" Height="16" />
</Button>
<AccessText Foreground="#262526"
FontWeight="Bold"
FontSize="12"
Width="Auto"
VerticalAlignment="Center"
HorizontalAlignment="Center">Source</AccessText>
</StackPanel>
</MenuItem.Header>
</MenuItem>
</Menu>
</Grid>
</Border>
</DockPanel>
</Window>
Изображение
Сетка
<Window
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"
mc:Ignorable="d"
Title="MainWindow" Width="1137.333"
WindowState="Maximized"
WindowStartupLocation="CenterScreen">
<DockPanel>
<!-- Menu Area -->
<Border VerticalAlignment="Top" DockPanel.Dock="Top" Margin="0,5,0,5">
<!-- Diagram Area -->
<Grid x:Name="DiagramPane" Margin="10,0,10,10">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Menu VerticalAlignment="Top" Grid.Row="0" Height="60" Margin="0,-7,0,0" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="1"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<MenuItem x:Name="OpenSourceView"
Background="Yellow"
Padding="0"
Height="60"
>
<MenuItem.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type MenuItem}}}"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" HorizontalAlignment="Center" Height="30" Width="30" Margin="0,0,0,0" IsDefault="True" Command = "{Binding AjoutCommand}" CommandParameter = "null">
<Image Opacity="0.4" HorizontalAlignment="Center" VerticalAlignment="Center" Source="/Images/AddFile.png" Grid.Column="2" Height="16" />
</Button>
<AccessText Foreground="#262526"
Grid.Row="1"
FontWeight="Bold"
FontSize="12"
Width="Auto"
VerticalAlignment="Center"
HorizontalAlignment="Center">Source</AccessText>
</Grid>
</MenuItem.Header>
</MenuItem>
</Menu>
</Grid>
</Border>
</DockPanel>
</Window>
Изображение
* Сердечно 1031 *