tags:

views:

893

answers:

3

Hi

I've a shell window constructed of an Header, Main Content and Footer. The main content is a tab control. According to the design, one of the tab items content (a user control) needs to expand a little bit over the footer. At first I thought about implmenting this with a negative Margin, but the footer no matter what I did always get drawn on top of my content.

For example consider the following xaml:

<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="33*"/>
    <RowDefinition Height="33*"/>
    <RowDefinition Height="33*"/>
  </Grid.RowDefinitions>
  <StackPanel Background="Blue" Grid.Row="0"/> <!-- Header -->
  <StackPanel Background="Red" Grid.Row="2"/>  <!-- Footer -->
  <TabControl Grid.Row="1"  > <!-- Content -->
    <TabItem>
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="33*"/>
          <ColumnDefinition Width="33*"/>
          <ColumnDefinition Width="33*"/>
        </Grid.ColumnDefinitions>
        <StackPanel Grid.Column="1" Background="Yellow" >
          <Button Width="100" Height="50" Content="Text"  />
        </StackPanel>
      </Grid>
  </TabItem>
</TabControl>

What I would want to achieve is making the Yellow StackPanel to reach the bottom of the screen somewhow, overlapping on top of the red footer.

Hope it is understandable. Thanks Ariel

+2  A: 

Try this code sample:

<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="33*"/>
    <RowDefinition Height="33*"/>
    <RowDefinition Height="33*"/>
  </Grid.RowDefinitions>
   <Grid.ColumnDefinitions>
     <ColumnDefinition Width="33*"/>
     <ColumnDefinition Width="33*"/>
     <ColumnDefinition Width="33*"/>
   </Grid.ColumnDefinitions>      
  <StackPanel Grid.ColumnSpan="3" Background="Blue" Grid.Row="0"/> <!-- Header -->
  <StackPanel Grid.ColumnSpan="3" Background="Red" Grid.Row="2"/>  <!-- Footer -->
  <TabControl Grid.ColumnSpan="3" Grid.Row="1"> <!-- Content -->
    <TabItem>
      <Grid>
          <Button Width="100" Grid.Column="1" Height="50" Content="Text"  />          
      </Grid>
    </TabItem>
  </TabControl>
    <StackPanel Grid.Column="1" Grid.Row="3" Background="Yellow" />
</Grid>
Arcturus
Thanks Dude, But you misunderstood. Bottom of the screen, not bottom of the Tab Control. The yellow stack panel need to be overlapped on top of the red one.
ArielBH
Ah my bad... changed my answer a bit :)
Arcturus
No. if you change the Grid.Row to 2, you will lose the Footer completely I want that only the Yellow StackPanel be over the Red, not the entire Tab Control.
ArielBH
How about this ? :)
Arcturus
Great, now you cover not only the footer but the header as well! :)
ArielBH
Close... how about now ? :)
Arcturus
:) not quite. The TabControl has lost his position on the middle of the screen...
ArielBH
And this ? I set the StackPanel now outside the TabControl...
Arcturus
Yeah, but this is a simple example. In my real application all content is injected in runtime to the tabacontrol, you can't put it out from them, and then you have the opposite problem, you want it still lapping the middle of the screen. Nevertheless I appreciate that you are trying hard to help me.
ArielBH
I am afraid you are stuck between a rock and a hard place.. You cannot really layout controls on other places if your controls are injected through the tabitem... You could try to use Margins, but that is going to be one ugly solution... Or perhaps you can use Canvas, which has no layout properties
Arcturus
More info on Canvas... http://msdn.microsoft.com/en-us/library/system.windows.controls.canvas.aspx
Arcturus
Wow. +1 for this answer even though it didn't solve the problem. The amount of effort put into this answer and its iterations deserves some StackOverflow pointage, people! :-)
Judah Himango
+1  A: 

The problem is that you want the stackpanel contained within the tab control, but you want it to extend beyond the bottom of the tab control. This isn't supported by the tab control.

Will
That true! I am looking for a work around
ArielBH
The workaround is to create a custom control for this. Or, rethink your design. I'm not sure why you want to do this or think its worth the effort, tho.
Will
You know, designers....
ArielBH
+1  A: 

No doubt TabControl is the problem. Maybe try to write your own TabControl.

Cheers.

Satumba