How to split a WPF window into two parts?

I want to create an application that has a list on the left (I will create it so that it looks good later).

On the right side, I want to have an area where I can add controls, etc.

So, the question is what I need to do to divide the Window into two unequal parts (the left side is about 350 pixels wide and the height should be the whole window), and the rest is for my "canvas".

+5
source share
2 answers

You can use the grid :

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="350" /> <!-- Or Auto -->
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <ListBox Grid.Column="0" />
    <Canvas Grid.Column="1" />
</Grid>

Or you can use the DockPanel :

<DockPanel>
    <ListBox DockPanel.Dock="Left" Width="350" />
    <Canvas />
</DockPanel>

Grid , GridSplitter.

+6

CodeNaked DockPanel, Canvas , , .

, ( ), DockPanel, , , .

<DockPanel LastChildFill="True">
    <ListBox DockPanel.Dock="Left" Width="350"/>
    <Canvas />
</DockPanel>
+4

All Articles