WPF general hidden control method (for example Header)

When using controls such as ListView, GridView, TreeView, etc., you often encounter the need to hide its Header.

Analysis: All WPF controls inherit from Control, so the so-called hidden Header is actually hiding the control that displays the Header.

The method introduced in this article, I think it can be applied to any other scene that needs to hide the control - that is, set the height or width to 0.

————————————————————————————————————————————————

Directly on the picture:

Create the GridViewColumnHeader type Style in the above picture as "noHearderStyle", set the height = 50, and refer to the above "noHearderStyle" for the HeaderContainerStyle in the GridViewColumn below, and you can see that the view is set correctly.

Then modify the height value to 10, the effect is as follows (you can see that it is blocked):

Then modify it to 0, and the hiding is realized (only the height of the control is 0, so you can’t see it, but it still takes up memory, but it’s not a big problem)

Guess you like

Origin blog.csdn.net/qq_23958061/article/details/114305782