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. WCF and WF
  4. Tabcontrol won't fill the window

Tabcontrol won't fill the window

Scheduled Pinned Locked Moved WCF and WF
questionwpfcomhelp
10 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.
  • Y Offline
    Y Offline
    Yoav Ben Zvi
    wrote on last edited by
    #1

    I have a tab control with 4 TabItems . The width of the tab control is the combined width of the 4 TabItems headers, instead of filling the window. How can I set it to fill the screen? Here is the code: xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="THEMIS" Height="630" Width="668" WindowState="Maximized">Desktop Messages Projects Administration Thanks for any help.

    M 1 Reply Last reply
    0
    • Y Yoav Ben Zvi

      I have a tab control with 4 TabItems . The width of the tab control is the combined width of the 4 TabItems headers, instead of filling the window. How can I set it to fill the screen? Here is the code: xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="THEMIS" Height="630" Width="668" WindowState="Maximized">Desktop Messages Projects Administration Thanks for any help.

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      One way would be to change the second StackPanel to a Grid. Mark p.s. If you're going to post XAML, please post valid XAML :)

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      Y 1 Reply Last reply
      0
      • M Mark Salsbery

        One way would be to change the second StackPanel to a Grid. Mark p.s. If you're going to post XAML, please post valid XAML :)

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        Y Offline
        Y Offline
        Yoav Ben Zvi
        wrote on last edited by
        #3

        I didn't notice until now that everything turned to lowercase :( I tried to do that and it worked, but then I applied a control template to the tabitems and it broke again. I hope the xaml is better this time:

        M 1 Reply Last reply
        0
        • Y Yoav Ben Zvi

          I didn't notice until now that everything turned to lowercase :( I tried to do that and it worked, but then I applied a control template to the tabitems and it broke again. I hope the xaml is better this time:

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          XAML looks good thanks :) I'm not sure what you're trying to do here...your tab control still fills the entire window. What's broken? Mark

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          Y 1 Reply Last reply
          0
          • M Mark Salsbery

            XAML looks good thanks :) I'm not sure what you're trying to do here...your tab control still fills the entire window. What's broken? Mark

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            Y Offline
            Y Offline
            Yoav Ben Zvi
            wrote on last edited by
            #5

            This is what I am seeing: http://farm4.static.flickr.com/3204/3138578581_e665ec2790.jpg?v=0

            M 1 Reply Last reply
            0
            • Y Yoav Ben Zvi

              This is what I am seeing: http://farm4.static.flickr.com/3204/3138578581_e665ec2790.jpg?v=0

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              I see that too - it's the way you templated it :) What do you want to see? Mark

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              Y 2 Replies Last reply
              0
              • M Mark Salsbery

                I see that too - it's the way you templated it :) What do you want to see? Mark

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                Y Offline
                Y Offline
                Yoav Ben Zvi
                wrote on last edited by
                #7

                It was supposed to be a menu, and beneath that a tab control with 4 tabitems. The headers of the tabitems (the section were you press to select the tab) are using a control template that replaces the normal look. It should look like this, but the now the tab won't stretch on the whole screen: http://farm4.static.flickr.com/3219/3139805444_91eedf8bdd.jpg?v=0 The code is in the next post (image link don't like 'ignore HTML tags)

                1 Reply Last reply
                0
                • M Mark Salsbery

                  I see that too - it's the way you templated it :) What do you want to see? Mark

                  Mark Salsbery Microsoft MVP - Visual C++ :java:

                  Y Offline
                  Y Offline
                  Yoav Ben Zvi
                  wrote on last edited by
                  #8

                  The code:

                  M 1 Reply Last reply
                  0
                  • Y Yoav Ben Zvi

                    The code:

                    M Offline
                    M Offline
                    Mark Salsbery
                    wrote on last edited by
                    #9

                    Your tab control still needs to be in an element that stretches its content, like a grid. When you wrap the TabControl in a grid, you'll see your TabItem template is messed up because of the "stack" of items in the header Grid. Maybe try nesting the TabItem header elements, something like this:

                    <Grid>
                        <Grid.Resources>
                            <ControlTemplate x:Key="TabItemTemplate" TargetType="{x:Type TabItem}">
                                <Grid>
                                    <Border x:Name="outerRec" Width="110" Height="30" CornerRadius="10" >
                                        <Border.Background>
                                            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                                <GradientStop Color="SteelBlue" Offset="0"/>
                                                <GradientStop Color="Red" Offset="1"/>
                                            </LinearGradientBrush>
                                        </Border.Background>
                                        <Border Width="105" Height="25" CornerRadius="10" >
                                            <Border.Background>
                                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                                    <GradientStop Color="White" Offset="0"/>
                                                    <GradientStop Color="Transparent" Offset="1"/>
                                                </LinearGradientBrush>
                                            </Border.Background>
                                            <Viewbox>
                                                <ContentControl Margin="4" Content="{TemplateBinding MenuItem.Header}"/>
                                            </Viewbox>
                                        </Border>
                                    </Border>
                                </Grid>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="MenuItem.IsMouseOver" Value="True">
                                        <Setter TargetName="outerRec" Property="Background" Value="SteelBlue"/>
                                    </Trigger>
                                    <Trigger Property="MenuItem.IsPressed" Value="True">
                                        <Setter Property="RenderTransform">
                                            <Setter.Value>
                                                <ScaleTransform ScaleX=".9" ScaleY=".9"/>
                                            </Setter.Value>
                                        </Setter>
                                        <Setter Property="RenderTransformOrigin" Value=".5,.5"/>
                    
                    Y 1 Reply Last reply
                    0
                    • M Mark Salsbery

                      Your tab control still needs to be in an element that stretches its content, like a grid. When you wrap the TabControl in a grid, you'll see your TabItem template is messed up because of the "stack" of items in the header Grid. Maybe try nesting the TabItem header elements, something like this:

                      <Grid>
                          <Grid.Resources>
                              <ControlTemplate x:Key="TabItemTemplate" TargetType="{x:Type TabItem}">
                                  <Grid>
                                      <Border x:Name="outerRec" Width="110" Height="30" CornerRadius="10" >
                                          <Border.Background>
                                              <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                                  <GradientStop Color="SteelBlue" Offset="0"/>
                                                  <GradientStop Color="Red" Offset="1"/>
                                              </LinearGradientBrush>
                                          </Border.Background>
                                          <Border Width="105" Height="25" CornerRadius="10" >
                                              <Border.Background>
                                                  <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                                      <GradientStop Color="White" Offset="0"/>
                                                      <GradientStop Color="Transparent" Offset="1"/>
                                                  </LinearGradientBrush>
                                              </Border.Background>
                                              <Viewbox>
                                                  <ContentControl Margin="4" Content="{TemplateBinding MenuItem.Header}"/>
                                              </Viewbox>
                                          </Border>
                                      </Border>
                                  </Grid>
                                  <ControlTemplate.Triggers>
                                      <Trigger Property="MenuItem.IsMouseOver" Value="True">
                                          <Setter TargetName="outerRec" Property="Background" Value="SteelBlue"/>
                                      </Trigger>
                                      <Trigger Property="MenuItem.IsPressed" Value="True">
                                          <Setter Property="RenderTransform">
                                              <Setter.Value>
                                                  <ScaleTransform ScaleX=".9" ScaleY=".9"/>
                                              </Setter.Value>
                                          </Setter>
                                          <Setter Property="RenderTransformOrigin" Value=".5,.5"/>
                      
                      Y Offline
                      Y Offline
                      Yoav Ben Zvi
                      wrote on last edited by
                      #10

                      Thanks a lot. Its working great.

                      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