Put resizable Expander to expand from right to left
Asked Answered
A

1

5

I would like to have the Expander from question below (see the accepted answer) which is a perfect solution for me. I just want to have it on the right side.

Combine expander and grid (resizable expander)

To have it expanded from right to left I changed the settings for an analoguous behavior. (I emphasized elements to see better what's going on):

<Expander Grid.Column="1" Header="Test" ExpandDirection="Left" 
        BorderThickness="10" BorderBrush="Black" HorizontalAlignment="Right" >
  <Expander.Content>
    <Grid >
       <Grid.ColumnDefinitions>
         <ColumnDefinition Width="Auto"/>
         <ColumnDefinition Width="Auto" />
       </Grid.ColumnDefinitions>
       <GridSplitter Grid.Column="0" Width="10" Background="Green" 
                  ResizeDirection="Columns" ResizeBehavior="CurrentAndNext" />
       <TextBox Grid.Column="1" Text="Lorem ipsum dolor sit" 
             BorderThickness="10" BorderBrush="Red"/>
    </Grid>
  </Expander.Content>
</Expander>

It resizes the area left from the splitter when I move the splitter to the right. I tried many other combinations but it almost resulted in the same unwanted behavior. The area left of the splitter is sometimes kind of weirdly exploding but TextBox remains unchanged.

Aelber answered 13/1, 2012 at 9:26 Comment(3)
What happens when you use PreviousAndCurrent as ResizeBehavior?Multicellular
not very clear question, try to put some images to show what you want plzMalefic
I'm only enabled to add images after 10 rep. points.... Generally the left edge of the expander moves, but Textbox and Splitter remain. @Daniel: With this setting, it just don't resizes at all.Aelber
S
11

Try like this:

<Expander Grid.Column="1" Header="Test" ExpandDirection="Left"
    BorderThickness="10" BorderBrush="Black" HorizontalAlignment="Right">
  <Expander.Content>
    <Grid>
       <Grid.ColumnDefinitions>
         <ColumnDefinition Width="*" MinWidth="10" />
         <ColumnDefinition Width="Auto" />
       </Grid.ColumnDefinitions>
       <GridSplitter Grid.Column="0" Width="10" Background="Green"
                  ResizeDirection="Columns" ResizeBehavior="CurrentAndNext" />
       <TextBox Grid.Column="1" Text="Lorem ipsum dolor sit"
             BorderThickness="10" BorderBrush="Red"/>
    </Grid>
  </Expander.Content>
</Expander>
Seddon answered 13/1, 2012 at 13:22 Comment(1)
Great! I wouldn't have thought it's the "star" width in the splitter column. In the preceding question the grid column had a fixed width. I'm still curious why that's not working hereAelber

© 2022 - 2024 — McMap. All rights reserved.