我一直在寻找一段时间,但我似乎无法找到为什么我的datagrid radiobutton列(这是生成)不能正常工作。我可以点击单选按钮,但它们不会改变。对于一些背景我正在做一个房地产管理程序,这个窗口是“编辑属性”页面。我正在创建一个数据网格,用户可以选择已经住在该财产以及当前(或最新)租户的租户。WPF DataGrid绑定Radiobutton列属性
这里是我的DataGrid的XAML:
<DataGrid VerticalScrollBarVisibility="Auto" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserResizeRows="False" CanUserAddRows="False" AutoGenerateColumns="False" Margin="5,0,0,0" Width="375" Height="100" ItemsSource="{Binding CurrentProperty.tennants}">
<DataGrid.Columns>
<DataGridCheckBoxColumn Header="Lived Here" Binding="{Binding something}"/> <!-- I'm still working on this. This is a totally different problem. I know how to bind. -->
<DataGridTemplateColumn Header="Current">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<RadioButton HorizontalAlignment="Center" GroupName="current" IsChecked="{Binding current, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="Name" Binding="{Binding name}"/>
</DataGrid.Columns>
</DataGrid>
目前,有5个租户,在DataGrid中显示出来(这是我想要什么)和其中一人有选择的当前单选按钮(这是我想要的)。我不能,但是选择不同的单选按钮。它只是取消选择当前的一个,直到我再次点击它。
谢谢。现在我已经为此疯狂了一段时间了。
我做到了。我不想要一个复选框。我想要一个单选按钮。在发布一个描述我是多么愚蠢的答案之前,请先正确地阅读这个问题。请在将来这样做。谢谢。 –
问题是关于模板单选按钮列。不是这样的:' '。我知道这并不完整。尽管如此,我仍然会编辑这个问题。 –
对不起,去年这些评论有多糟糕。我刚回到这个问题,因为它有1000多个意见。我的心情一定很糟糕。感谢您提供的帮助。 –