Skip to main content
Home Forums Silverlight Programming Report a Silverlight Bug RC0: TabControl Style with ControlTemplate no longer works
4 replies. Latest Post by EricBowman on October 14, 2008.
(0)
paupdb
Member
8 points
15 Posts
09-29-2008 10:34 PM |
In my application I have a Style that I created to remove the annoying margins that the default TabControl puts on its content panel.In SL 2 Beta 2, this Style worked perfectly. Now in RC0, it doesn't - I don't get any errors, but nothing shows in the TabControl, not even the TabItem tabs.
Interestingly, the Style I have applied to my TabItems to remove margins there works fine still in RC0.
Below is the TabControl Style, its basically the same as the default TabControl style, just with Margin = 0 on the ContentHost:
<!-- Marginless TabControl and TabItem Style --> <Style TargetType="winctrl:TabControl" x:Key="MarginlessTabControlStyle"> <Setter Property="IsEnabled" Value="False" /> <Setter Property="IsTabStop" Value="False" /> <Setter Property="Background" Value="White" /> <Setter Property="Foreground" Value="#FF313131" /> <Setter Property="FontFamily" Value="Trebuchet MS" /> <Setter Property="FontSize" Value="11" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="winctrl:TabControl"> <Grid x:Name="Root"> <Grid.Resources> <!-- Brushes --> <SolidColorBrush x:Key="BorderBrush" Color="#FF000000" /> <SolidColorBrush x:Key="DisabledBrush" Color="#A5FFFFFF" /> </Grid.Resources> <vsm:VisualStateManager.VisualStateGroups> <vsm:VisualStateGroup x:Name="CommonStates"> <vsm:VisualStateGroup.Transitions> <vsm:VisualTransition GeneratedDuration="0" /> </vsm:VisualStateGroup.Transitions> <vsm:VisualState x:Name="Normal" /> <vsm:VisualState x:Name="Disabled"> <Storyboard> <DoubleAnimation Storyboard.TargetName="Disabled1" Storyboard.TargetProperty="Opacity" To="1" Duration="0" /> </Storyboard> </vsm:VisualState> </vsm:VisualStateGroup> </vsm:VisualStateManager.VisualStateGroups> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <primitives:TabPanel x:Name="TabPanel" Canvas.ZIndex="1" Grid.Column="0" Grid.Row="0" /> <Border x:Name="ContentBorder" Background="{TemplateBinding Background}" BorderBrush="{StaticResource BorderBrush}" BorderThickness="1" Grid.Column="0" Grid.Row="1" MinHeight="10" MinWidth="10" CornerRadius="0,0,2,2"> <ContentControl x:Name="ContentHost" Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}" Margin="0" /> </Border> <Rectangle x:Name="Disabled1" Canvas.ZIndex="1" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Grid.RowSpan="2" IsHitTestVisible="False" Fill="{StaticResource DisabledBrush}" Opacity="0" /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
I suspect the default TabControl ControlTemplate has changed somewhere.
09-30-2008 2:19 AM |
Update to this - this is no longer a bug for me. I found the updated documentation for RC0 (through VS Help) and managed to dig up the new TabControl ControlTemplate (which has changed dramatically from Beta 2).
I then discovered on close inspection of the new TabControl ControlTemplate that one can now set the margins on the ContentControl through the TabControl.Padding property. Which means I no longer need a custom Style or ControlTemplate anymore :)
Timmy G
64 points
51 Posts
10-01-2008 5:56 PM |
Can you tell me where I can find the xaml for these controls? I'm trying to use my own control template for the tabcontrol and cannot get it to work in RC0. I grabbed the default style from the SilverlightDefaultStyleBrowser and just tried to use it as is (no changes) and my test app won't run.
10-01-2008 6:09 PM |
Nevermind. I found the problem: that tool (SilverlightDefaultStyleBrowser) was showing me the new RC0 xaml (so I no longer need to find it in the help file). The catch was that I couldn't use that xaml until I moved the primative namespace declaration out of the style and into the root. Then it worked and now I can tweak the tab control's control template.
EricBowman
50 points
29 Posts
10-14-2008 12:19 PM |
paupdb,
Will you please post where you found the documentation, all I can find is the Beta 2 documentation.
Thank you.
Eric