Hi,
I am trying to override the background color of a tabitemheader for a tabcontrol which uses a theme. Unfortunately this doesn't seem to work.
I followed the example in http://es.infragistics.com/community/blogs/andrew_smith/archive/2009/12/09/common-style-issues-when-using-the-theme-property.aspx but if I use the BasedOn property the theme doesn't seem to get overriden and if I don't use it I lose the complete theme styling.
Example project in attachement
Hello pvdbpvdb,
The below definition of a style (based on another style) is just setting the “Background” property of the TabItemEx class.
<igWindows:XamTabControl Theme="Office2k7Silver">
<igWindows:XamTabControl.Resources>
<Style TargetType="{x:Type igWindows:TabItemEx}" BasedOn="{x:Static igThemes:PrimitivesOffice2k7Silver.TabItemEx}">
<Setter Property="Background" Value="Red" />
</Style>
</igWindows:XamTabControl.Resources>
…
If you try setting the “Background” property without style it will not work either:
<igWindows:TabItemEx Header="TabItem1" Background="Red">
The reason for this is the theme which is set. The theme defines some containers in the tab’s header which are “over” the tab’s background.
To see your style definition working you may try setting some other property, for example try the “FontWeight”:
<Setter Property="FontWeight" Value="Bold" />
Sincerely,
Radko
Senior Software Developer
Hello Radko,
It seems that redifining the tabheader like you did does work without losing the theme. It's not the perfect solution as it doesn't fill the whole tab header with the new background color but it will do. I will mark your answer as verified.
On a side note does anyone know why the BasedOn property doesn't work with the themes? Because this would seem like the proper way to fix this.
Here is an example on how to set a data trigger on a custom created element (Border) inside the tab item’s header to make its background color change based on a specific property value:
<igWindows:TabItemEx>
<igWindows:TabItemEx.Header>
<Border Padding="4" Margin="-4" >
<Border.Style>
<Style TargetType="Border">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=chb, Path=IsChecked}" Value="True">
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=chb, Path=IsChecked}" Value="False">
<Setter Property="Background" Value="Green" />
</Style.Triggers>
</Border.Style>
<TextBlock Text="Tab Label" />
</Border>
</igWindows:TabItemEx.Header>
… tab content here …
</igWindows:TabItemEx>
<CheckBox IsThreeState="False" x:Name="chb">Change Color</CheckBox>
Added difficulty would be that I need to change the background only one one specific tabheader and only in certain conditions. I was planning to do this with a datatrigger and as far as i know it is impossible to change a brush definition in a datatrigger with the setter property.