根据wpf中的某些条件禁用datagrid中单元格中的复选框
我想根据某些条件禁用包含复选框的单元格。我已经实现了这一点,即该复选框看起来确实模糊且被禁用,但是当我单击它时,该复选框被选中,即它实际上没有被禁用。以下是我
在xaml中
<toolkit:DataGridCheckBoxColumn Header="Del?" Binding="{Binding DeleteFlag, Mode=Default}" Width="45" IsReadOnly="True" >
<toolkit:DataGridCheckBoxColumn.ElementStyle>
<Style TargetType="{x:Type CheckBox}">
<Setter Property="IsEnabled" Value="{Binding Path=SortPos, Converter={x:Static my:RowReadOnlyConverter.Instance}}" />
</Style>
</toolkit:DataGridCheckBoxColumn.ElementStyle>
</toolkit:DataGridCheckBoxColumn>
尝试过的代码,上面突出显示的“SortPos”将整数值发送到“RowReadOnlyConverter”类,该类实现了IValueConverter
接口,该接口返回一个布尔值基于某种条件。虽然这工作正常,但该复选框不会像上面提到的那样被禁用。我还尝试过“IsHitTestVisible”而不是“IsEnabled”。有谁知道除上述之外的任何其他可能有效的财产或任何其他解决方案?
如果您需要查看“RowReadOnlyConverter”类或想要该行为的屏幕截图,请告诉我。
I want to disable a cell containing a checkbox based on some condition. I have achieved this i.e. the checkbox does look blurred and disabled but when i click it the checkbox gets checked i.e. it is actually not getting disabled. The following is the code i have tried out
In xaml
<toolkit:DataGridCheckBoxColumn Header="Del?" Binding="{Binding DeleteFlag, Mode=Default}" Width="45" IsReadOnly="True" >
<toolkit:DataGridCheckBoxColumn.ElementStyle>
<Style TargetType="{x:Type CheckBox}">
<Setter Property="IsEnabled" Value="{Binding Path=SortPos, Converter={x:Static my:RowReadOnlyConverter.Instance}}" />
</Style>
</toolkit:DataGridCheckBoxColumn.ElementStyle>
</toolkit:DataGridCheckBoxColumn>
The "SortPos" highlighted above sends an integer value to "RowReadOnlyConverter" class which implements the IValueConverter
interface which returns a bool value based on some condition. Although this works fine, the checkbox does not get disabled as mentioned above. I have also tried "IsHitTestVisible" instead of "IsEnabled". Does anyone know of any other property which might work or any other solution other than the above mentioned?
Please let me know if you need to have a look at "RowReadOnlyConverter" class or want a screenshot of the behavior.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需在Xaml文件中这样写..这里isstopprocess是复选框列,可编辑是基于此列的另一列isstopprocess列正在禁用..好吧..
just write like this in Xaml file ..here isstopprocess is the checkbox column ,is editable is another column based on this column isstopprocess column is disabiling..ok..