我有一个DataGrid复选框&其他文本框。绑定DataGrid基于复选框属性的TextBox启用
<DataGrid AutoGenerateColumns="False" Height="170" Name="dataGrid1" Width="527" OpacityMask="#FF161A1A" BorderBrush="#FFB7B39D" Background="LightYellow" RowBackground="LightGray" AlternatingRowBackground="#FFFFFFF5" BorderThickness="10" CanUserResizeRows="False" CanUserReorderColumns="False" CanUserResizeColumns="True" CanUserSortColumns="False" FontFamily="Segoe UI" FontSize="13" CanUserAddRows="False">
<DataGrid.Columns>
<DataGridCheckBoxColumn Header="" Binding="{Binding BoolProperty, Mode=TwoWay}" />
<DataGridTextColumn Header="" Binding="{Binding header}" MinWidth="108" IsReadOnly="True" />
<DataGridTextColumn Header="Number of Cases" Binding="{Binding cases}" >
<DataGridTextColumn.EditingElementStyle>
<Style TargetType="TextBox">
<Setter Property="IsEnabled" Value="{Binding Path=BoolProperty, Mode=TwoWay}" />
</Style>
</DataGridTextColumn.EditingElementStyle>
</DataGridTextColumn>
checkboxcolumn绑定到“BoolProperty”。如果BoolProperty为false,我希望文本框的“Number of Cases”被禁用,如果BoolProperty为true,则启用它。我尝试在TExtBox中添加IsEnabled,但它不起作用。我哪里错了?
你为什么要编辑编辑风格? –
@MArk,看了很多后,我从这个网站的解决方案得到了这个想法 - http://wpf.codeplex.com/discussions/44656 – Tvd