I want to create a scalable Menu control in my application. I used this answer to create a scalable window and then inserted the Menu control into it. I have some issues and cannot find a solution.
How to set the "center" vertical adjustment for the menu items? Now they are docked to the top. Are there any ways to move the first item ("File" in my case) to the right a bit?
And is it possible to avoid cutting of menu panel during window resizing? For now, even if I move the top border of inner grid a bit down, the menu panel is cut by half.
My code and its results for full-screen and smaller scale are below:
<Window x:Class="DigitalSteelCastingWPF.MainWindow"
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"
xmlns:local="clr-namespace:DigitalSteelCastingWPF"
mc:Ignorable="d"
Title="Digital Steel Casting"
Name="myMainWindow"
Height="1056" Width="1936"
WindowStartupLocation="CenterScreen" WindowState="Maximized"
FontSize="24"
HorizontalAlignment="Center" VerticalAlignment="Center"
WindowStyle="ThreeDBorderWindow">
<Grid Name="MainGrid" SizeChanged="MainGrid_SizeChanged">
<Grid.LayoutTransform>
<ScaleTransform x:Name="ApplicationScaleTransform"
CenterX="0"
CenterY="0"
ScaleX="{Binding ElementName=myMainWindow, Path=ScaleValue}"
ScaleY="{Binding ElementName=myMainWindow, Path=ScaleValue}" />
</Grid.LayoutTransform>
<Grid VerticalAlignment="Center" HorizontalAlignment="Center" Height="1025" Width="1928">
<StackPanel VerticalAlignment="Top">
<Menu Width="Auto" Height="50" VerticalAlignment="Center" FontSize="24">
<MenuItem Header="_File">
<MenuItem x:Name="New" Header="_New" Height="50" HorizontalAlignment="Left" Width="250"/>
<MenuItem x:Name="Open" Header="_Open" Height="50" HorizontalAlignment="Left" Width="250"/>
<MenuItem x:Name="Exit" Header="_Exit" Height="50" HorizontalAlignment="Left" Width="250"/>
</MenuItem>
<MenuItem Header="_Tools">
<MenuItem x:Name="Options" Header="O_ptions" Height="50" HorizontalAlignment="Left" Width="250"/>
</MenuItem>
</Menu>
</StackPanel>
</Grid>
</Grid>
</Window>