I have an application with a lot of ListView controls using the GridView layout. All of these use a custom Style customStyle. I want to disable column reordering in all of these ListView controls.
Can I do this without touching all of the controls using the existing Style? I tried this, but it doesn't seem to work:
<Style x:Key="customStyle"
BasedOn="{StaticResource ResourceKey={x:Type ListView}}"
TargetType="{x:Type ListView}">
<Setter Property="GridView.AllowsColumnReorder" Value="False" />
...
</Style>
Thanks!
Update: If this is not possible, is there a way to disable the column reordering by default in my application?
Update:
I also tried this, which doesn't work. Probably because GridView doesn't have a Style property.
<Style TargetType="{x:Type GridView}">
<Setter Property="AllowsColumnReorder" Value="False" />
...
</Style>
Here's what you should have done:
In this style definition
<Style x:Key="{x:Static GridView.GridViewScrollViewerStyleKey}" TargetType="ScrollViewer">
There is a
<GridViewHeaderRowPresenter
And it has an attribute AllowsColumnReorder hard code it to false.
...
I know ... Two year old thread. But I bet people still read it.
Just simply add this attributes to your datagrid tag
CanUserResizeColumns="False"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With