Live Chat Icon For mobile
Live Chat Icon

WPF FAQ - Expander

Find answers for the most frequently asked questions
Expand All Collapse All

If you require justifying the Expander button to the right, you need to set the FlowDirection property to RightToLeft.

Note: If you set the FlowDirection to RightToLeft, the content of the expander will also be moved to RightToLeft justification. In order to avoid this, you can set the flow direction to expander content. This can be done with the following code snippets,


<Expander FlowDirection="RightToLeft">
                <TextBlock Text="Expander header content" Background="AliceBlue"
                           AncestorType={x:Type Expander}},
            <Grid FlowDirection="LeftToRight">
                <TextBlock Background="Gray" Text="Expander body content"/>

This example shows how to create an Expander control that contains complex content such as an image and text. The example also encloses the content of the Expander in a ’ScrollViewer’ control.


<Expander Width='200' HorizontalContentAlignment='Stretch'>
         <Image Width='10' Source='images\icon.jpg'/>
       <TextBlock Margin='20,0,0,0'>My Expander</TextBlock>
     <ScrollViewer Height='50'>
       <TextBlock TextWrapping='Wrap'>
         Lorem ipsum dolor sit amet, consectetur adipisicing elit, 
         sed do eiusmod tempor incididunt ut labore et dolore magna 
         aliqua. Ut enim ad minim veniam, quis nostrud exercitation 
         ullamco laboris nisi ut aliquip ex ea commodo consequat. 
         Duis aute irure dolor in reprehenderit in voluptate velit 
         esse cillum dolore eu fugiat nulla pariatur. Excepteur sint 
         occaecat cupidatat non proident, sunt in culpa qui officia 
         deserunt mollit anim id est laborum.


Share with

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

Please submit your question and answer.