我有一个,当我不希望用户更改任何内容时DataGrid
,我当前设置为该位置,然后我有一个按钮供用户单击以允许修改,然后更改为 falseReadOnly
IsReadOnly
但现在的问题是,当 时DataGrid.IsReadOnly = true
,滚动被禁用。如何使 DataGridIsReadOnly=true
或类似的并且仍然能够滚动DataGrid
?
数据网格样式:
<DataGrid.Style>
<Style TargetType="{x:Type DataGrid}">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ReadOnly}" Value="True"/>
<Condition Binding="{Binding Reordering}" Value="False"/>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="IsReadOnly" Value="True" />
<Setter Property="IsHitTestVisible" Value="False" />
<Setter Property="Foreground" Value="Gray" />
</MultiDataTrigger.Setters>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ReadOnly}" Value="True"/>
<Condition Binding="{Binding Reordering}" Value="True"/>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="IsHitTestVisible" Value="False" />
<Setter Property="IsReadOnly" Value="True" />
</MultiDataTrigger.Setters>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ReadOnly}" Value="False"/>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="IsHitTestVisible" Value="True" />
<Setter Property="IsReadOnly" Value="False" />
</MultiDataTrigger.Setters>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</DataGrid.Style>