Articles in this section
Category / Section

How to create WPF GridSplitter in C# with 3 panels?

4 mins read

Before we get to know about WPF GridSplitter, we should know about Grid panel.

Grid Panel

The grid is a layout panel that arranges rows and columns for their children in a tabular structure. Let us divide a panel into three parts.

<Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Label Content="Panel: Left - Top" 
               HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
               BorderBrush="Black" BorderThickness="1"
               Grid.Row="0" Grid.Column="0"/>
        <Label Content="Panel: Left - Bottom" 
               HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
               BorderBrush="Black" BorderThickness="1"
               Grid.Row="1" Grid.Column="0"/>
        <Label Content="Panel: Right"
               HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
               BorderBrush="Black" BorderThickness="1"
               Grid.Column="1" Grid.RowSpan="2"/>
    </Grid>

 

   

GridSplitterDemo

From the screenshot above, we can see that a grid panel is used to divide the format into two rows and a column with two labels assigned to the left column and one label assigned to the right column. Now let us allow end users to resize the size of rows and columns using grid splitter.

Grid Splitter

In the grid panel created above, size of the rows and columns are equally divided. You can let your end users to resize these rows and columns according to their need using grid splitter. You can see two grid splitters are added in below code snippet. Grid splitter is smart enough to detect and resize columns and rows, based on where it is aligned.

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Label Content="Panel: Left - Top" 
               HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
               Grid.Row="0" Grid.Column="0"/>
        <Label Content="Panel: Left - Bottom" 
               HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
               Grid.Row="1" Grid.Column="0"/>
        <Label Content="Panel: Right"
               HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
               Grid.Column="1" Grid.RowSpan="2"/>
        <GridSplitter HorizontalAlignment="Right" VerticalAlignment="Stretch" 
                      Grid.RowSpan="2" Width="5"/>
        <GridSplitter HorizontalAlignment="Stretch" VerticalAlignment="Bottom" 
                      Height="5"/>
    </Grid>

 

 

GridSplitter_GIF

Sample: https://github.com/SyncfusionExamples/How-to-create-grid-splitter-in-C-with-3-panels-/tree/master/GridSplitter

 

Conclusion

I hope you enjoyed learning about how to create WPF GridSplitter in C# with 3 panels.

You can refer to our WPF GridSplitter feature tour page to know about its other groundbreaking feature representations and documentation, to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied