0

I'm using Dragablz and Mahapps and I want to be able to switch between modern Material Design type tabs and the trapezoid ones. I've created two TabablzControl styles I can switch between and have a CustomHeaderViewModel I can change too to adjust its appearance to fit the changing tab style. My header has a stack panel with a textblock and an icon. I can change the background colour of the SP but in the trapezoid mode I do not know how to change the trapezoid's background to match the colour theme chosen.

Here's my two styles:

        <Style TargetType="{x:Type dragablz:TabablzControl}" x:Key="TabablzControlStyle">
            <Setter Property="NewItemFactory" Value="{x:Static stUi:UINewItem.Factory}" />
            <Setter Property="ItemsSource" Value="{Binding Items}" />
            <Setter Property="ClosingItemCallback" Value="{Binding ClosingTabItemHandler}" />
            <Setter Property="ShowDefaultCloseButton" Value="False" />
            <Setter Property="AdjacentHeaderItemOffset" Value="-10" />
            <Setter Property="ItemContainerStyle" Value="{StaticResource TrapezoidDragableTabItemStyle}" />
            <Setter Property="HeaderMemberPath" Value="Header" />
            <Setter Property="Background" Value="Red"/>
            <Setter Property="InterTabController" Value="{StaticResource InterTabController}" />
            <Setter Property="Margin" Value="0 8 0 0" />
        </Style>

        <Style TargetType="{x:Type dragablz:TabablzControl}" x:Key="ModernControlStyle">
            <Setter Property="NewItemFactory" Value="{x:Static stUi:UINewItem.Factory}" />
            <Setter Property="ItemsSource" Value="{Binding Items}" />
            <Setter Property="ClosingItemCallback" Value="{Binding ClosingTabItemHandler}" />
            <Setter Property="ShowDefaultCloseButton" Value="False" />
            <Setter Property="AdjacentHeaderItemOffset" Value="0" />
            <Setter Property="HeaderMemberPath" Value="Header" />
            <Setter Property="InterTabController" Value="{StaticResource InterTabController}" />
            <Setter Property="Margin" Value="0 8 0 0" />
        </Style>

Example:

You can see the area around the stackpanel is lighter than the SP itself. How do I change the trapezoid colour?

Thanks, Steve

Steve
  • 33
  • 1
  • 9

2 Answers2

0

Well, I could not find an elegant way to do this so I added code to find the "Trapezoid" type in the Loaded() function of my custom header code:

        var trap = TryFindParent<Trapezoid>(this);

        if (null != trap)
        {
            trap.Background = Application.Current.Resources["AccentColorBrush1"] as SolidColorBrush;
        }

TryFindParent from here : How can I find WPF controls by name or type?

It will do for me. Changing colour will typically only be done once and the setting saved.

Thanks

Steve
  • 33
  • 1
  • 9
0

I think that you can create new style based on TrapezoidDragableTabItemStyle and override the Background property.

After that you must set this new style in ItemContainerStyle property of the TabablzControl.

blackgreen
  • 18,419
  • 19
  • 55
  • 71
Daniel
  • 38
  • 5