Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit Problem with SilverLight Tab Control
5 replies. Latest Post by prujohn on January 8, 2009.
(0)
Chinu
Member
4 points
5 Posts
01-07-2009 5:10 AM |
Hi, sorry for the earlier post.. Can somebody please help me out.. Here is my Xaml Code<UserControl x:Class="SilverLightTab.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:y="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" Width="776" Height="504"> <Grid x:Name="LayoutRoot" Background="White"> <y:TabControl Height="64" VerticalAlignment="Top" Margin="0,0,328,0" > <y:TabItem Header="FirstTab" > <Grid> <TextBlock Text="1" Grid.Row="0" Grid.Column="0"/> </Grid> </y:TabItem> <y:TabItem Header="SecondTab"> <Grid> <TextBlock Text="2"/> </Grid> </y:TabItem> <y:TabItem Header="ThirdTab"> <Grid> <TextBlock Text="3"/> </Grid> </y:TabItem> <y:TabItem Header="FourthTab"> <Grid> <TextBlock Text="4"/> </Grid> </y:TabItem> <y:TabItem Header="FifthTab"> <Grid> <TextBlock Text="5"/> </Grid> </y:TabItem> <y:TabItem Header="SixthTab"> <Grid> <TextBlock Text="6"/> </Grid> </y:TabItem> <y:TabItem Header="SeventhTab"> <Grid> <TextBlock Text="7"/> </Grid> </y:TabItem> </y:TabControl> </Grid></UserControl>Whenever I set My TabControl's width and height according to my convenience and then add some no.(say 13) of tab items to it and try to open them one by one.. then it goes fine till the moment there is sufficient space in the tabStrip of the tabControl to accomodate 'y'(y<x) tab items.. but if i want to open some more no. of tabs it stacks them onto the top of previous tabs by default if my the width of tabControl is less... so that my content portion of my selected Tab Item gets hidden sometimes in this stack of tab items..So,"how to align all the opened tab Items in a single row(obviously as i open more tabs then the total width of tab control some will get hidden but that is acceptable as long as my opened tab items are in their "Original Size").. and not allow it to stack on top of each other.. and maintain the 'Original Size' of the tabs"..(at least whenever i drop my mouse over it).. Any Clues Please
Deepak www.cerebrata.com
prujohn
Contributor
3579 points
704 Posts
01-07-2009 11:19 AM |
You could try putting your tab control inside of a ScrollViewer (with horizontal scrolling enabled). Then set an explicit width for your tab control, such that it won't resize, but the ScrollViewer will resize (because of it's relationship to the Grid parent). This should prevent tabs from wrapping, and at the same time allow you to scroll horizontally when necessary. Something like this:
<Grid x:Name="LayoutRoot" Background="White"> <ScrollViewer HorizontalScrollBarVisibility="auto" VerticalScrollBarVisibility="auto"> <y:TabControl Height="64" VerticalAlignment="Top" Width="750" > <y:TabItem Header="FirstTab" > <Grid> <TextBlock Text="1" Grid.Row="0" Grid.Column="0"/> </Grid> </y:TabItem> <y:TabItem Header="SecondTab"> <Grid> <TextBlock Text="2"/> </Grid> </y:TabItem> <y:TabItem Header="ThirdTab"> <Grid> <TextBlock Text="3"/> </Grid> </y:TabItem> <y:TabItem Header="FourthTab"> <Grid> <TextBlock Text="4"/> </Grid> </y:TabItem> <y:TabItem Header="FifthTab"> <Grid> <TextBlock Text="5"/> </Grid> </y:TabItem> <y:TabItem Header="SixthTab"> <Grid> <TextBlock Text="6"/> </Grid> </y:TabItem> <y:TabItem Header="SeventhTab"> <Grid> <TextBlock Text="7"/> </Grid> </y:TabItem> </y:TabControl> </ScrollViewer> </Grid>
01-07-2009 11:51 PM |
Thanks John.. but this is not what i desire..As I said I want all these opened tab items to be aligned in a single row.. just like it is the case in Visual Studio.. where you have some fix no. of tabs on the screen.. and another container for all other active tabs opened by you that cannot be accomodated in that control..
So now can you help me.. I am really stuck in it.. dont know how to get around..
01-07-2009 11:56 PM |
hm I guess I don't understand what you mean then, can you post a link to a picture of what you are talking about?
01-08-2009 1:12 AM |
Hi prujohn.
.these are the links to the images : 1)Tab Control problem Image (http://www.cerebrata.com/images/tmp/TabControlProblem.jpg)2)Desired Solution Image (http://www.cerebrata.com/images/tmp/DesiredTabControl.jpg)
Can you help me to get the Desired Solution now..??
01-08-2009 9:48 AM |
Ah yes, now I know exactly what you mean. You're talking about the tab overflow. For Silverlight this would require some fairly heavy customization. The good news is that it was just announced today that the Silverlight Controls are now open source, so you can derive from TabControl and extend it to your needs.
http://timheuer.com/blog/archive/2009/01/08/silverlight-controls-source-code-released.aspx