tags:

views:

401

answers:

2

Hai presently i have grid like this.

    <Grid  Name="tGrid1"  Grid.Row="0" Background="Black" >
    </Grid>



    <Grid Name="Grid2"  Grid.Row="1"  Background="LightBlue" >
    </Grid>



    <Grid Name="Grid3"  Grid.Row="2" Background="LightGray" Height="auto" >

    </Grid>




    <Grid Name="Grid4"   Grid.Row="3"   Background="LightGreen" >
    <Button HorizontalAlignment="Left" IsEnabled="True" Margin="13.5,5,0,5" Name="TestBtn" Width="50" Click="test_Click" >Test</Button>
    </Grid>

</Grid>

What i want is, when i click the Test button Grid 1 and Grid 2 has to collapsed and the space has to be occupied with Grid 3.That means the out of total height of 500 of Outer Grid , Grid 3 should occupy height=465 and Grid 4 should ocupy Height=35. How can i do this? How should i change my height definitions of Grid ? Thanx in advance Kaja

A: 

Not sure if this is what you're asking, but in the test_Click method you could use this:

  private void test_Click(object sender, RoutedEventArgs e)
  {
     tGrid1.Width = 0;
     tGrid1.Height = 0;
     Grid2.Width = 0;
     Grid2.Height = 0;

     Grid3.Height = 465;
     Grid4.Height = 35;
  }

If by "collapse" you mean "hide", this will work by setting the height and width on tGrid1 and Grid2 to 0.

Donut
this is not working.Its removes the Grid1 and Grid2 but the Grid3 is not expanded.Anyway thanku 4 ur time.Let me know if u find any other way
Kaja
A: 

Hai i found the solution.

  <DockPanel  >
 <Grid  Name="tGrid1"  Grid.Row="0" DockPanel.dock="Top" Background="Black" >
 </Grid>

 <Grid Name="Grid2"  Grid.Row="1"  DockPanel.dock="Top" Background="LightBlue" >
 </Grid>

<Grid Name="Grid4"   Grid.Row="3"  DockPanel.dock="Bottom"  Background="LightGreen" >
<Button HorizontalAlignment="Left" IsEnabled="True" Margin="13.5,5,0,5" Name="TestBtn" Width="50" Click="test_Click" >Test</Button>
 </Grid>

<Grid Name="Grid3"  Grid.Row="2" DockPanel.dock="Top" Background="LightGray" Height="auto" >

</Grid>
</DockPanel>




 private void test_Click(object sender, RoutedEventArgs e)
  {
     tGrid1.visibility=visibility.collapsed;
Grid2.visibility=Visibility.collapsed;
  }

This works fine. Thank you Kaja

Kaja