Which StackPanel is your StackPanel Name="statusSP"
?
If it is the outermost layer of the StackPanel you could refer to the following code. It works fine when HorizontalAlignment="Right"
is set.
<DockPanel LastChildFill="False">
<StackPanel DockPanel.Dock="Top" Name="statusSP" HorizontalAlignment="Right" >
<Image Source="Images\tu.jfif" Stretch="Fill" Margin="5" Width="300" Height="100" HorizontalAlignment="Left" />
<StackPanel Orientation="Horizontal">
<Label Content="System Status:" Margin="10,10,10,10" FontSize="30" FontWeight="Bold"/>
<Label Name="statusLBL" Content="Ready" Margin="10,10,10,10" FontSize="30" FontWeight="Bold" Foreground="Red"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Mode:" Margin="10,10,10,10" FontSize="30" FontWeight="Bold"/>
<ListBox SelectionMode="Single" MaxHeight="30" ItemsSource="{Binding}" DataContext="{StaticResource modes}"
ScrollViewer.VerticalScrollBarVisibility="Visible">
</ListBox>
</StackPanel>
</StackPanel>
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Center" Margin="20,20,20,20">
<Button Content="Stop" Margin="20,10,40,10" FontSize="36" FontWeight="Bold" Width="120"/>
<Button Content="Quit" Margin="40,10,20,10" FontSize="36" FontWeight="Bold" Width="120"/>
</StackPanel>
</DockPanel>
The result:
If you still have questions, you can describe which control you want to set.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.