Dillinger
Dillinger

Reputation: 1903

TabItem MouseOver style disappeared with custom resource

I'm using Mahapp.metro I've created a custom header for set the font size, for doing this I've maded a statis resource in the TabControl.Resources, see:

<TabControl.Resources>
    <Style x:Key="headerStyle" TargetType="{x:Type TextBlock}">
          <Setter Property="Control.FontFamily" Value="Bauhaus 93" />
          <Setter Property="Control.FontSize" Value="12" />
          <Setter Property="Control.Foreground" Value="DimGray" />
     </Style>
</TabControl.Resources>

and this is how I've applied the resource:

<TabItem>
    <TabItem.Header>
         <TextBlock Text="Modalità notifiche" Style="{StaticResource headerStyle}" FontFamily="Segoe UI" FontWeight="Bold"/>
         </TabItem.Header> 
         ...

Now there is a problem, the Mahapp.metro control style is disappeared, I've only the header with a gray font, so the user can't see if the tab clicked is selected or not, how can I recover this property? Maybe Mahapp.metro offers another simple solution to do this without create any static resource? I doesn't find the TabControl on the documentation sites.

Upvotes: 0

Views: 60

Answers (1)

wingerse
wingerse

Reputation: 3796

When you set the Style yourself, you have overridden the implicit style set by MahApps. If you want to keep the implicit type, you can base your existing style on that like so:

<Style x:Key="headerStyle" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource {x:Type TextBlock}}">
      <Setter Property="Control.FontFamily" Value="Bauhaus 93" />
      <Setter Property="Control.FontSize" Value="12" />
      <Setter Property="Control.Foreground" Value="DimGray" />
 </Style>

Yes, Mahaps does offer an attached property to change the header font size. You can use controls:ControlsHelper.HeaderFontSize on a TabItem to get the effect.

Upvotes: 1

Related Questions