tags:

views:

329

answers:

3

Is there a way you can pin a wpf dockpanel? I have searched on the net and I have not found any functionality that will allow this. What I want is to lock the size of a dockpanel's dock regions. For example I want the right region"s width to stay locked all the time. The only solutions to this that I have seen are 3rd party controls. Does anyone know of a way to restrict the width of these regions? Thanx in advance.

A: 

You can set the MaxWidth property of the control you are docking.

DancesWithBamboo
I have tried setting the maxwidth and minwidth on the control getting set in the dock panel and it did not seem to work. Maybe I should explain my problem a little more. I am nesting a dockpanel in a row of a grid layout. The row is small. Within this dockpanel i have a horizontal itemscontrol that grows in the left dock and some buttons in the right dock. I want the buttons to stay the same size and not get pushed or overlapped by the items control. This is happening when the items control size reaches those buttons. Is there a way to make sure the right dock panel does not shrink.
prem_data
Set the dockpanel's LastChildFill property to true. Dock the buttons to the right and don't set the docking property for the itemscontrol.
DancesWithBamboo
Tried as you suggested and that still did not work. Still pushed the buttons off on the right. Any other ideas?
prem_data
A: 

According to your additional explanations, you have the following layout:

<DockPanel>
    <ItemsControl DockPanel.Dock="Left"/>
    <StackPanel DockPanel.Dock="Right"/>
</DockPanel>

The first thing I recommend is to add LastChildFill="False" to the DockPanel so your left and right parts grow unrelated.

Then you have to decide what happens when the number of items in the ItemsControl increase. You can make a horizontal scrollbar appear, make them wrap, and so on.

Mart
A: 

Yes, I had LastChildFill = "False" already set, plus the my items control is already in a scrollviewer with a horizontal template applied. With this setup the initial layout looks great in the row. The only problem is when the itemscontrol grows too big and hits the right dock, it will always force the right dock to go smaller even though the minwidth is set on the grid that is contained within. Here is an example of my code:

  <DockPanel Grid.Row="1" LastChildFill="False">

                <!--Horizontal template applied-->
                <ScrollViewer  DockPanel.Dock="Left">
                    <ItemsControl/>    
                </ScrollViewer>

                <Grid DockPanel.Dock="Right" MinWidth="200">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>                            
                    </Grid.ColumnDefinitions>
                    <Button Grid.Column="0"/>
                    <Button Grid.Column="1"/>                                
                </Grid>
  </DockPanel>

Thanks for the help . . . any other ideas?

prem_data