wpfdevexpresstoolbardevexpress-wpf

How to set the dev express toolbar background style wpf


Here is my xaml, the background properties are not rendered for any devexpress control. How to override the inbuilt properties.

      <dxb:ToolBarControl ShowBackground="False" Grid.Row="0"  HorizontalAlignment="Stretch" 
                        VerticalAlignment="Top"
                        AllowCustomizationMenu="True" 
                        BarItemDisplayMode="ContentAndGlyph" UseWholeRow="True" 
                        AllowHide="False" AllowQuickCustomization="False" RotateWhenVertical="False">
        <dxb:ToolBarControl.Background>
            <LinearGradientBrush EndPoint="1,1"  StartPoint="0,0">
                <GradientStop Color="#a9546a" Offset="0.1" />
                <GradientStop Color="#b4506d" Offset="0.2" />
                <GradientStop Color="#9e3763" Offset="0.3" />
                <GradientStop Color="#ac4362" Offset="0.5" />
                <GradientStop Color="#8a3470" Offset="0.75" />
                <GradientStop Color="#753c83" Offset="1.0" />
            </LinearGradientBrush>
        </dxb:ToolBarControl.Background>
     </dxb:ToolBarControl>

Solution

  • To change ToolBarControl's background, override the BarControlThemeKey ResourceKey=BarTemplate resource.

    xmlns:dxbt="http://schemas.devexpress.com/winfx/2008/xaml/bars/themekeys"
    ...
    <Window.Resources>
        <ControlTemplate x:Key="{dxbt:BarControlThemeKey ResourceKey=BarTemplate, IsThemeIndependent=True}" TargetType="{x:Type ContentControl}">
            <Border x:Name="Background" Background="Red">
                <ContentPresenter/>
            </Border>
        </ControlTemplate>
    </Window.Resources>
    

    To learn more about customizing DevExpress resources, please refer to How to find and change an inner DevExpress control template