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>
I solved this using a attached dependency property for the ListView control. This property will then set the property on the GridView. From my Style I can then set this attached dependency property. Still not a nice solution, but it works.