WPF : Collapsing the visibility of a grid [modified]
-
I've three grids inside a main grid as following:
<Grid Margin="10,10,10,10" Background="#FFE8E8E8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.2*" />
<ColumnDefinition Width="0.5*" />
<ColumnDefinition Width="0.3*" />
</Grid.ColumnDefinitions>
<Grid x:Name="RedGrid" Margin="0,0,0,0" Grid.Column="0" Background="Red"/>
<GridSplitter Width="4" VerticalAlignment="Stretch" Grid.Column="0"/>
<Grid x:Name="GreenGrid" Margin="0,0,0,0" Grid.Column="1" Background="Green"/>
<GridSplitter Width="4" VerticalAlignment="Stretch" Grid.Column="1"/>
<Grid x:Name="BlueGrid" Margin="0,0,0,0" Grid.Column="2" Background="Blue"/>
</Grid>I need two behaviors 'CollapseRed' and 'CollapseBlue'. CollapseRed - should collapse RedGrid(left) panel, and then GreenGrid(centre) panel should automatically cover the space on the left side. CollapseBlue - should collapse BlueGrid(right) panel, and then GreenGrid(Centre) panel should automatically cover the space on the right side. Grids are resizable with grid-splitters, and so, we should be able to make it visible again at same place/width by using separate behaviors. Simple 'Visibility.Collapse' is not working. What change should I make in XAML, and what should be code in C#? Should I use other panels? If yes, please suggest. So basically, I need functionality somewhat similar to SplitContainer of WinForms, where we can just on/off/change orientation of BlueGrid panel. And, Green panel adjusts accordingly.
modified on Thursday, April 29, 2010 4:20 AM
-
I've three grids inside a main grid as following:
<Grid Margin="10,10,10,10" Background="#FFE8E8E8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.2*" />
<ColumnDefinition Width="0.5*" />
<ColumnDefinition Width="0.3*" />
</Grid.ColumnDefinitions>
<Grid x:Name="RedGrid" Margin="0,0,0,0" Grid.Column="0" Background="Red"/>
<GridSplitter Width="4" VerticalAlignment="Stretch" Grid.Column="0"/>
<Grid x:Name="GreenGrid" Margin="0,0,0,0" Grid.Column="1" Background="Green"/>
<GridSplitter Width="4" VerticalAlignment="Stretch" Grid.Column="1"/>
<Grid x:Name="BlueGrid" Margin="0,0,0,0" Grid.Column="2" Background="Blue"/>
</Grid>I need two behaviors 'CollapseRed' and 'CollapseBlue'. CollapseRed - should collapse RedGrid(left) panel, and then GreenGrid(centre) panel should automatically cover the space on the left side. CollapseBlue - should collapse BlueGrid(right) panel, and then GreenGrid(Centre) panel should automatically cover the space on the right side. Grids are resizable with grid-splitters, and so, we should be able to make it visible again at same place/width by using separate behaviors. Simple 'Visibility.Collapse' is not working. What change should I make in XAML, and what should be code in C#? Should I use other panels? If yes, please suggest. So basically, I need functionality somewhat similar to SplitContainer of WinForms, where we can just on/off/change orientation of BlueGrid panel. And, Green panel adjusts accordingly.
modified on Thursday, April 29, 2010 4:20 AM
Can you try DockPanel instead of outer grid.
Arun Jacob http://codepronet.blogspot.com/
-
Can you try DockPanel instead of outer grid.
Arun Jacob http://codepronet.blogspot.com/
Hmm.. but then, can we use GridSplitters inside a DockPanel? If yes, how?
-
Hmm.. but then, can we use GridSplitters inside a DockPanel? If yes, how?
Try this if it suits your requirement, DockPanel Splitter Control for WPF[^]
Arun Jacob http://codepronet.blogspot.com/
-
Try this if it suits your requirement, DockPanel Splitter Control for WPF[^]
Arun Jacob http://codepronet.blogspot.com/
Yeah! That could be one way. It helps. Thanks!!