Disable column resizing in ListView

In my window there is a ListView in which there are several columns. Some or all of the columns cannot be resized by the user, since they already have the optimal width and accidental resizing only worsens it. Now there are some answers to this question, but they all end up with restyled control. Unfortunately, I ended up with numerous pages of XAML code that are highly platform / theme specific. When I create a copy of the default style with Blend, I get a lot of gradients, etc. Which work only with Win7 Aero, but not in the XP theme or something else will come.

Thus, replacing the entire style of the control is not an option. (It almost never happens.)

I have already defined the part that should be hidden, it is called "PART_HeaderGripper". I did such things before, removing the current glow and other parts from the ProgressBar with the following code in the code:

var glow = progressBar.Template.FindName("PART_GlowRect", progressBar) as FrameworkElement; if (glow != null) glow.Visibility = visibility; 

But this does not work with GridViewColumnHeader, because Template.FindName does not find anything (returns null). I am sure there must be a way to change the visual effects at runtime. But I can’t figure it out now. Any idea?

+4
source share
1 answer

Checked by:

 <GridViewColumnHeader Content="Value" IsHitTestVisible="False"/> 
+7
source

Source: https://habr.com/ru/post/1436405/


All Articles