Skip to main content

How to Modify RibbonControl Items and Properties in DiagramDesignerControl

  • 2 minutes to read

There are several ways to customize the built-in RibbonControl:

  • Use the RibbonControl’s Merging feature. Create an external RibbonControl with required elements and attach the MergingProperties.ElementMergingBehavior property to DiagramDesignerControl. After performing this, elements form the DiagramDesignerControl’s ribbon will be merged with the parent ribbon.
  • Customization actions. Using customization actions, you can create/remove/update bar items. Use the DiagramDesignerControl.Actions property to define customization actions. The DefaultBarItemNames class contains default item captions displayed in the diagram’s Ribbon. The DefaultBarItemNames document describes how the members of this class correspond to the Ribbon’s elements.
  • Overriding theme styles. Almost all bar items in DiagramDesignerControl have styles defined as DynamicResource. You can override these styles and set required properties in them. Refer to the following topic for more information on how to modify theme resources: Customize Themes.
<ResourceDictionary 
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
                    xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
                    xmlns:dxdiag="http://schemas.devexpress.com/winfx/2008/xaml/diagram"
                    xmlns:dxdiagt="clr-namespace:DevExpress.Xpf.Diagram.Themes;assembly=DevExpress.Xpf.Diagram.v16.1"
                    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
                    xmlns:sys="clr-namespace:System;assembly=mscorlib">

    <Style x:Key="{dxdiagt:DesignerControlCommandsThemeKeys ResourceKey=PasteCommandItemStyle, IsThemeIndependent=True}" TargetType="{x:Type dxb:BarButtonItem}">
        <Style.Setters>
            <Setter Property="Content" Value="Custom Paste"/>
            <Setter Property="Glyph" Value="{dx:DXImage Image=GlobalColorScheme_16x16.png}"/>
            <Setter Property="LargeGlyph" Value="{dx:DXImage Image=GlobalColorScheme_32x32.png}"/>
            <Setter Property="Command" Value="{Binding Commands.Paste, RelativeSource={RelativeSource TemplatedParent}}"/>
        </Style.Setters>
    </Style>
</ResourceDictionary>