I'm trying to center vertically a label
within a StackPanel
. I have already defined the VerticalAlignment="Center"
attribute but noticed no difference in vertical positioning, as can be seen in the image below. That is, the label remains aligned to the top.
TheXAML
alsofollows:
<UserControlx:Class="FoxCcoManagerMainScreen.FixedHeaderControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FoxCcoManagerMainScreen"
mc:Ignorable="d" Width="405" Height="77.5">
<StackPanel Orientation="Vertical">
<Rectangle Height="45" Stroke="Black" Fill="#FFFF7400"/>
<StackPanel Height="30" Background="#FF1B1B1B">
<Label x:Name="label" Content="Home" VerticalAlignment="Center" Height="25" Margin="10,0,0,0" FontFamily="Segoe WP" FontSize="13.333" Foreground="White" HorizontalAlignment="Left" Width="50"/>
</StackPanel>
</StackPanel>
</UserControl>