문제

I am using a WrapPanel and because I want to save space I want to remove (not hide) some controls (some of them are group boxes) depending on some features.

What command should I use to remove a control?

도움이 되었습니까?

해결책

You can use Remove() method or its variant, such as RemoveRange() & RemoveAt(), to remove control(s) from a panel :

myWrapPanel.Children.Remove(myGroupBox);

Or simply set Visibility property to Collapsed on controls that you want to hide :

myGroupBox.Visibility = Visibility.Collpased;

That won't cause empty space reserved for those hidden controls as described in MSDN :

Visibility.Collapsed: Do not display the element, and do not reserve space for it in layout.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top