spiegelp / MaterialDesignExtensions

Material Design Extensions is based on Material Design in XAML Toolkit to provide additional controls and features for WPF apps
https://spiegelp.github.io/MaterialDesignExtensions/
MIT License
754 stars 122 forks source link

Can't specify font size for TabItem Header #81

Closed jbooth88 closed 4 years ago

jbooth88 commented 4 years ago

Would be a nice-to-have if TabControlAssist could manipulate the TabItem header font size. Looks like the current value is hard-coded to 14pt in the style xaml.

spiegelp commented 4 years ago

@jbooth88 I would like to suggest you an alternative solution: The TabItem.Header property is of type object. You can add your own TextBlock with the desired style. Please have a look at TabControlControl.xaml line 119 for getting an example of a complex header.

I prefer this way to keep the library API and code compact. Otherwise, every new and fancy idea for the style would result in a new property and inflated XAML code. That is why I suggest you the WPF default way for customization.

jbooth88 commented 4 years ago

There is a visual style in the TabItem XAML that is lost if an alternate header (like a TextBlock) is used. I understand the design choice. No worries.

spiegelp commented 4 years ago

@jbooth88 I guess you are missing the color of an active tab? It is important to set the Foreground like the demo code in TabControlControl.xaml at line 119 and following. Please have a look at this minimal code example:

<TabItem.Header>
    <TextBlock FontSize="8"
               Text="HEADER TEXT"
               Foreground="{Binding Path=(mde:TabControlAssist.TabHeaderForeground), RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabItem}}}" />
</TabItem.Header>
jbooth88 commented 4 years ago

Weird. I could have sworn when I applied a custom header last time, it disabled the storyboard for the border animation (defined in the MaterialDesignTabControl style template).

After trying again, everything seems ok. Must have been something on my side. What you have provided solves my original issue. Thanks for your time!