将可调整大小的扩展器从右向左扩展 [英] Put resizable Expander to expand from right to left

查看:247
本文介绍了将可调整大小的扩展器从右向左扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从下面的问题中得到Expander(参见接受的答案),这对我来说是一个完美的解决方案。我只想把它放在右边。

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.

合并扩展器和网格(可调整大小的扩展器)

为了让它从右向左扩展,我改变了类似行为的设置。 (我强调元素可以更好地了解正在发生的事情):

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.

推荐答案

尝试像这样:

<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>

这篇关于将可调整大小的扩展器从右向左扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆