Vertically center a label on the StackPanel

0

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.

TheXAMLalsofollows:

<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>
    
asked by anonymous 18.12.2016 / 18:16

1 answer

2

You need to align the StackPanel center with your label. Your label is centrally aligned if you pay close attention. The StackPanel holding the label is not aligned.

    
18.12.2016 / 18:38