我正在尝试对ListBoxItem
的内容进行对齐。 在下面的示例中,我想要在每一行的ListBox
中将TextBlock
左对齐和Button
右对齐。 但是,按钮总是直接跟随TextBlock的文本结尾,没有在ListBox
中右对齐。
<StackPanel>
<ListBox ItemsSource="{Binding MyDataList}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding SomeTextProperty}"
VerticalAlignment="Center" Margin="5" />
<Button Content="Display"
HorizontalAlignment="Right" Margin="5"
Command="{Binding SomeCommand}"
CommandParameter="{Binding}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
我想我的XAML需要做出一些改变,不知道哪里出了问题?
谢谢您的帮助!