我需要根据触发器禁用特定列的编辑,但不起作用。
<DataGridTextColumn Binding="{Binding Qty,UpdateSourceTrigger=PropertyChanged}" Header="QTY" Width="100">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Right"></Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding ItemType}" Value="Discount">
<Setter Property="IsEnabled" Value="False"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
答案 0 :(得分:0)
添加:
<DataGridTextColumn.EditingElementStyle>
<Style TargetType="TextBox">
<Setter Property="HorizontalAlignment" Value="Right"></Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding ItemType}" Value="Discount">
<Setter Property="IsEnabled" Value="False"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGridTextColumn.EditingElementStyle>