SIGN UP MEMBER LOGIN:    
ARTICLE

Gridsplitter with tab controls in WPF 4 Using Expression Blend 4.0

Posted by Nipun Tomar Articles | WPF with C# May 13, 2011
This article will demonstrate how to set up a WPF Gridsplitter in XAML and also using tab controls with Microsoft Expression Blend.
Reader Level:
Download Files:
 

This article will demonstrate how to set up a WPF Gridsplitter in XAML and also using tab control with Microsoft Expression Blend.

Open a new WPF application in Expression Blend 4.0 and name it "GridSplitter".

 Gridsplitter1.jpg

1. Change the name of your layout root to "MyGrid".

Gridsplitter2.jpg
   
2. Add Rows and columns to it using the code below:

<Grid.RowDefinitions>
    <RowDefinition Height="150*" />
    <RowDefinition Height="3*" />
    <RowDefinition Height="150*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
    <ColumnDefinition Width="250*" />
    <ColumnDefinition Width="5*" />
    <ColumnDefinition Width="590*" />
</Grid.ColumnDefinitions>

Your window will look like this:

Gridsplitter3.jpg

3. Add a new grid to the existing Grid and change its background: 

<Grid Background="#FFDAC9BB"  Grid.Column="0"></Grid>

Gridsplitter4.jpg  

4. Select GridSplitter which is available in the Assets library under the head "All controls". And add it in the grid; first we are adding "Vertical Splitter".
Gridsplitter5.jpg 

<GridSplitter Grid.Row="0" Grid.Column="1" Background="Black"
   HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto"
   Height="Auto" Grid.RowSpan="3" ResizeDirection="Columns">
</GridSplitter>


5. And similarly for the second column add a new grid to it:

<Grid Grid.Row="0" Grid.Column="2" Background="#FFACDDED" ></Grid>

And then add Horizontal Splitter by using the below code:

<GridSplitter Grid.Row="1" Grid.Column="0" Background="Black"
       HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Width="Auto"
       Height="Auto" Grid.ColumnSpan="3" ResizeDirection="Rows">
</GridSplitter>

Gridsplitter6.jpg 

6. And lastly two more grids to the remaining columns:

<Grid Grid.Row="2" Grid.Column="0" Background="#FFF7E2F5" ></Grid>
<Grid Grid.Row="2" Grid.Column="2" Background="#FFB2F9B3"></Grid>

Gridsplitter7.jpg 

7. Let's add some controls to it, for example Tab Control tabcontrol.jpg . It is also available in the Assets Library.

Add the tab control to the first Grid as under:

<Grid Background="#FFDAC9BB"  Grid.Column="0">
  <TabControl Margin="8" Name="TabControl1"/>
</Grid>

And then Tab item:

<TabItem  Header="Vegetables" Background="#FF002B81" Foreground="Black"/>
    
Gridsplitter8.jpg 

8. Now in that "TabItem" add one more grid and then in a grid add listbox with it's items:

<Grid>
        <ListBox Background="#FFB2B6E9"  Margin="0,0,8.615,0">
            <ListBoxItem>LadyFinger</ListBoxItem>
            <ListBoxItem>Onion</ListBoxItem>
            <ListBoxItem>Patato</ListBoxItem>
            <ListBoxItem>Peas</ListBoxItem>
            <ListBoxItem>Carrot</ListBoxItem>
            <ListBoxItem>Cawliflower</ListBoxItem>
            <ListBoxItem>Cabbage</ListBoxItem>
            <ListBoxItem>Beans</ListBoxItem>
        </ListBox>
</Grid>

Gridsplitter9.jpg

9. Similarly you can add more tab items to your tab control. As I have added:

Gridsplitter10.jpg
 
10. You can now add the tab controls and tab items to your rest of the grids and can change the background as well as Foreground according to you.

So, at last my window looks like:

Gridsplitter11.jpg 

Login to add your contents and source code to this article
share this article :
post comment
 

How can I click on Fruits and see the fruit lists

Posted by Suzana Br Nov 28, 2011

How can I click on Fruits and see the fruit lists

Posted by Suzana Br Nov 28, 2011
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Become a Sponsor