WPF GridSplitter to split / resize two ListBox lists?

I have a grid that has 7 rows. Line 0 is a group of two buttons Line 1 is a ListBox of objects Line 2 is a group of three buttons Line 3 is a group of 2 buttons Line 4 is where my GridSplitter lives Line 5 is a group of 2 buttons Line 6 is a listbox of objects

I want the GridSplitter to move up and down by resizing each of the two ListBoxs. Now I have life on its own line, and when I click it, it freezes when it hits the top of line 4 (its own line) and just creates an empty space while it extends line 4 down.

I just need this splitter to move up and down and resize each ListBox. These lists currently have vertical scrollbars if they become too large to view them.

any ideas?

+3
source share
2 answers

Here is some XAML that shows how to use GridSplitteras you described:

<Grid VerticalAlignment="Stretch">  
  <Grid.RowDefinitions>
    <RowDefinition Height="10" />
    <RowDefinition Height="10" />
    <RowDefinition Height="10" />
    <RowDefinition Height="10" />
    <RowDefinition Height="10" />
    <RowDefinition Height="10" />
    <RowDefinition Height="*" />
    <RowDefinition Height="*" />
  </Grid.RowDefinitions>

  <Rectangle Grid.Row="0" Fill="Red" />
  <Rectangle Grid.Row="1" Fill="Orange" />
  <Rectangle Grid.Row="2" Fill="Yellow" />
  <Rectangle Grid.Row="3" Fill="Green" />
  <Rectangle Grid.Row="4" Fill="Blue" />
  <Rectangle Grid.Row="5" Fill="LightBlue" />

  <ListBox Grid.Row="6" Background="Indigo">
    <ListBoxItem>Hello</ListBoxItem>
    <ListBoxItem>World</ListBoxItem>
  </ListBox>

  <GridSplitter Grid.Row="7" Height="5" Background="Gray"
                VerticalAlignment="Top" HorizontalAlignment="Stretch" />

  <ListBox Grid.Row="7" Background="Violet" Margin="0,5,0,0">
    <ListBoxItem>Hello</ListBoxItem>
    <ListBoxItem>World</ListBoxItem>
  </ListBox>
</Grid>

GridSplitter . ( , ), . , 5, 5 ListBox, - .

, .

+6

: GridSplitter ( ) , . , HorizontalAlignment = "Stretch" .

XAML:

<GridSplitter Grid.Row="2" Grid.Column="2" Height="5" ResizeDirection="Rows" VerticalAlignment="Center" />

XAML:

    <GridSplitter Grid.Row="2" Grid.Column="2" Height="5" ResizeDirection="Rows" VerticalAlignment="Center" HorizontalAlignment="Stretch"/>

, , , XAML GridSplitter (.. ), GridSplitter GridSplitter . , BackGround (, "" ).

HorizontalAlignment ( ): http://msdn.microsoft.com/en-us/library/ms743457.aspx

0

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


All Articles