尝试本教程 http://www.wpftutorial.net/ListBoxDataTemplate.html
并考虑添加一个单选按钮,如下所示
<ListBox Margin="10" ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="20"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" Margin="5" BorderBrush="Black" BorderThickness="1">
<Image Source="{Binding Path=Image}" Stretch="Fill" Width="50" Height="50" />
</Border>
<StackPanel Grid.Column="1" Margin="5" >
<StackPanel Orientation="Horizontal" TextBlock.FontWeight="Bold" >
<TextBlock Text="{Binding Path=Some1}" />
<TextBlock Text="{Binding Path=Firstname, FallbackValue=FirstName}" />
<TextBlock Text="{Binding Path=Lastname, FallbackValue=LastName}" Padding="3,0,0,0"/>
</StackPanel>
<TextBlock Text="{Binding Path=Age, FallbackValue=Age}" />
<TextBlock Text="{Binding Path=Role, FallbackValue=Role}" />
</StackPanel>
<RadioButton Grid.Column="2" Margin="5" HorizontalAlignment="Right" GroupName="A1"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
但结果输出是
将单选按钮与列表框边缘右侧对齐有什么帮助吗?谢谢
最佳答案
首先你需要get the template content to stretch ,然后您可以创建一个内容在右侧对齐的内容。
关于c# - 如何在 WPF 中右对齐 RadioButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9756651/