Menu

#90 Old Themes (ie. Brushed Metal *, Solid Color *, etc.) cannot override ControlTemplates for some controls.

1.26.1.0
closed
None
2021-05-20
2021-05-20
madproton
No

Old Themes (ie. Brushed Metal , Solid Color , etc.) cannot override ControlTemplates for the following:

1. FavoritesBar.xaml
2. MainTabControl.xaml
3. TabItemControl.xaml

Referencing a local ControlTemplate does not allow a Dynamic ControlTemplate to replace it.
For example:

<!--FavoritesBar.xaml-->
<ContentControl

             Template="{DynamicResource ContentControlControlTemplate1}">

    <ContentControl.Resources>
        <ControlTemplate x:Key="ContentControlControlTemplate1" TargetType="{x:Type ContentControl}"></ControlTemplate>
    </ContentControl.Resources>

Solution:

Moved ControlTemplates of the following files to Themes\Default\SystemControlStyles.xaml. Enclose ControlTemplate in Style and also moved style properties.

1. FavoritesBar.xaml
2. MainTabControl.xaml
3. TabItemControl.xaml

    <Style TargetType="{x:Type local:FavoritesBar}">
        <Setter Property="Margin" Value="{DynamicResource FavoritesBar.Margin}" />
        <Setter Property="Padding" Value="{DynamicResource FavoritesBar.Padding}" />
        <Setter Property="Background" Value="{DynamicResource FavoritesBar.Background}" />
        <Setter Property="BorderBrush" Value="{DynamicResource FavoritesBar.BorderBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource FavoritesBar.Border.Thickness}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ContentControl}"></ControlTemplate>
            </Setter.Value>
        </Setter>
</Style>

Discussion


Log in to post a comment.