Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get adjustable "frames" in WPF?

I know I have several options to use when it comes to dividing up my window into separate sections (e.g., DockPanel, StackPanel, etc). My Windows application requires that the user be able to adjust the size of different sections at runtime, similar to how a user can adjust FRAME widths in HTML. Does anyone have suggestions for what type/types of controls to use to accomplish this in C# WPF? If you have any code that would illustrate how a user can mouse-over a section boundary and click-hold to adjust the size, that would be ideal.

like image 890
Doug Avatar asked May 04 '26 10:05

Doug


1 Answers

System.Windows.Controls.GridSplitter

http://msdn.microsoft.com/en-us/library/system.windows.controls.gridsplitter.aspx

Example:

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

    <ListBox Grid.Row="0" >
        <TextBlock>Hello</TextBlock>
    </ListBox>

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

    <ListBox Grid.Row="2" >
        <TextBlock>World</TextBlock>            
    </ListBox>
</Grid>
like image 166
Eric Dahlvang Avatar answered May 05 '26 22:05

Eric Dahlvang