【发布时间】:2014-02-03 08:06:25
【问题描述】:
我一直在寻找一段时间,但我似乎无法找到为什么我的 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 个租户(这是我想要的),其中一个选择了当前单选按钮(这是我想要的)。我不能,但是选择一个不同的单选按钮。它只是取消选择当前的,直到我再次单击它。
谢谢。我已经为此发疯了一段时间了。
【问题讨论】:
标签: wpf xaml data-binding datagrid