How can I bind the Expander’s header element’s Width to the ActualWidth of the Expander ?

Platform: WPF| Category: Expander

This can be done with the following code snippet.

[XAML]
<Expander>
            <Expander.Header>
                <TextBlock Text="Expander header content" Background="AliceBlue"
                           Width="{Binding
                           RelativeSource={RelativeSource
                           Mode=FindAncestor,
                           AncestorType={x:Type Expander}},
                           Path=ActualWidth}"/>
            </Expander.Header>
  
            <TextBlock Background="Gray" Text="Expander body content"/>
             
</Expander>

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.