Vertically center a label on Stackpanel

Asked

Viewed 133 times

0

I’m trying to center vertically on one label within a StackPanel. I’ve already defined the attribute VerticalAlignment="Center" but I didn’t notice any difference in vertical positioning, as can be seen in the image below. That is, the label remains aligned to the top.

inserir a descrição da imagem aqui

Also follows the XAML:

<UserControl x: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>

1 answer

2


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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.