How to hide title in WPF Expander?

I have a business requirement: when a user clicks on a flag in a WPF application, he will display panels depending on which checkboxes they select. I would like to use the expander panel, but I'm not sure how to hide the title. The user is not allowed to see him if they have not checked the box. Somebody knows?

+4
source share
3 answers

You can do this by creating your own Style for your Expander .

However, it may be easier to simply place the controls in another panel and set the visibility to Collapseed in response to the state of the checkbox. The main reason for using Expander is to have a title and controls.

+4
source

Until you idealize, you could go this route ...

<Expander> <Expander.Header> <TextBlock Visibility="{Binding IsExpanded, RelativeSource={RelativeSource AncestorType={x:Type Expander}, Mode=FindAncestor}, Converter={StaticResource BoolToVisibilityConverter}}">My Expander</TextBlock> </Expander.Header> </Expander> 

... where the BoolToVisibilityConverter is something like ...

  public class BoolToVisibilityConverter : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if ((bool)value) return Visibility.Visible; return Visibility.Collapsed; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if ((Visibility)value == Visibility.Visible) return true; return false; } #endregion } 
+2
source

This answer has everything you need: WPF Expander Button Stylized to fit inside the Expander header

If you use a style that it mentions and does not specify the contents of the title, the title disappears

0
source

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


All Articles