我一直在尋找一段時間,但我似乎無法找到爲什麼我的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多個意見。我的心情一定很糟糕。感謝您提供的幫助。 –