So I have a few buttons on my project and I would like to align the images and the text so that it looks something like this. (Made in Photoshop)
And this is what mine looks like
What would be the propper way to accomplish this?
XAML
<Button x:Name="BtnPlay" Width="Auto" Background="Transparent" BorderThickness="0" Height="35"
Margin="-1,69,687,262" Style="{DynamicResource MenuButtonStyle}">
<StackPanel Orientation="Horizontal" Width="89">
<Image Source="Icons/newPower.png" Width="30" Height="27" />
<TextBlock FontWeight="Bold" Foreground="White" Text="Play" VerticalAlignment="Center"
Margin="3,-1,3,-2" Height="18" Width="32" />
</StackPanel>
</Button>
<Button x:Name="BtnSettings" Width="Auto" Background="Transparent" BorderThickness="0" Height="35"
Margin="0,265,686,66" Style="{DynamicResource MenuButtonStyle}">
<StackPanel Orientation="Horizontal">
<Image Source="Icons/newWrench.png" Width="20" Height="20" />
<TextBlock FontWeight="Bold" Foreground="White" Text="Settings" VerticalAlignment="Center"
Margin="3,-1,3,3" />
</StackPanel>
</Button>
<Button x:Name="BtnUsers" Width="Auto" Background="Transparent" BorderThickness="0" Height="35"
Margin="1,139,687,191" Style="{DynamicResource MenuButtonStyle}">
<StackPanel Orientation="Horizontal">
<Image Source="Icons/newUser.png" Width="20" Height="20" Margin="1,1,25,1" />
<TextBlock FontWeight="Bold" Foreground="White" Text="Users" VerticalAlignment="Center"
Margin="3,-1,3,3" />
</StackPanel>
</Button>
<Button x:Name="BtnPortforward" Width="Auto" Background="Transparent" BorderThickness="0" Height="35"
Margin="1,104,687,226" Style="{DynamicResource MenuButtonStyle}">
<StackPanel Orientation="Horizontal">
<Image Source="Icons/newWorld.png" Width="20" Height="20" />
<TextBlock FontWeight="Bold" FontSize="10" Foreground="White" Text="Portforward"
VerticalAlignment="Center" Margin="3,-1,3,3" />
</StackPanel>
</Button>
<Button Name="BtnUpdate" Width="Auto" Background="Transparent" BorderThickness="0" Height="35"
Margin="-1,331,686,0" Style="{DynamicResource MenuButtonStyle}">
<StackPanel Orientation="Horizontal">
<Image Source="Icons/newUpdate.png" Width="20" Height="20" />
<TextBlock FontWeight="Bold" Foreground="White" Text="Update" VerticalAlignment="Center"
Margin="3,-1,3,3" />
</StackPanel>
</Button>
<Label Content="Up to date!" Foreground="White" HorizontalAlignment="Left" Margin="10,305,0,0"
VerticalAlignment="Top" />
2
Answers
Grid
is more powerful thenStackPanel
and suited for more granular and complex designs/layoutsExmaple
You can use usercontrol.
And you can easy to use this usercontrol.