Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. WPF : Collapsing the visibility of a grid [modified]

WPF : Collapsing the visibility of a grid [modified]

Scheduled Pinned Locked Moved WPF
csharpwpfcsswinformsquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Prasoon Chaudhary
    wrote on last edited by
    #1

    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

    A 1 Reply Last reply
    0
    • P Prasoon Chaudhary

      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

      A Offline
      A Offline
      Arun Jacob
      wrote on last edited by
      #2

      Can you try DockPanel instead of outer grid.

      Arun Jacob http://codepronet.blogspot.com/

      P 1 Reply Last reply
      0
      • A Arun Jacob

        Can you try DockPanel instead of outer grid.

        Arun Jacob http://codepronet.blogspot.com/

        P Offline
        P Offline
        Prasoon Chaudhary
        wrote on last edited by
        #3

        Hmm.. but then, can we use GridSplitters inside a DockPanel? If yes, how?

        A 1 Reply Last reply
        0
        • P Prasoon Chaudhary

          Hmm.. but then, can we use GridSplitters inside a DockPanel? If yes, how?

          A Offline
          A Offline
          Arun Jacob
          wrote on last edited by
          #4

          Try this if it suits your requirement, DockPanel Splitter Control for WPF[^]

          Arun Jacob http://codepronet.blogspot.com/

          P 1 Reply Last reply
          0
          • A Arun Jacob

            Try this if it suits your requirement, DockPanel Splitter Control for WPF[^]

            Arun Jacob http://codepronet.blogspot.com/

            P Offline
            P Offline
            Prasoon Chaudhary
            wrote on last edited by
            #5

            Yeah! That could be one way. It helps. Thanks!!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups