[英]WPF disable DataGrid Cell
I would like to disable [read only] a DataGridCell
based on the program returned from database. 我想基于数据库返回的程序禁用[只读]
DataGridCell
。 I am using the following code but it's not working 我正在使用以下代码,但无法正常工作
<DataGridTextColumn Width="SizeToCells" x:Name="amountColumn" Header="Amount" Binding="{Binding Amount}" MinWidth="100" >
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell">
<Style.Triggers>
<DataTrigger Binding="{Binding RoleName}" Value="Payment Authoriser" >
<Setter Property="Background" Value="#DDA0DC" />
<Setter Property="ToolTip" Value="Please Add Amount" />
</DataTrigger>
</Style.Triggers>
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
<Setter Property="DedableThisCell" Value="Please DesableMe" />
GridCell
will be only writable when RoleName="Payment Maker"
ELSE anything for RoleName
, It will be readonly. GridCell
将只有写在RoleName="Payment Maker"
的还有什么别的RoleName
,这将是只读的。
Have you tried something like this? 你尝试过这样的事情吗?
<DataTrigger Binding="{Binding RoleName}" Value="Payment Maker" >
<Setter Property="IsEnabled" Value="True" />
</DataTrigger>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.