Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

ThemedWindow.ToolbarItemContainerStyleSelector Property

Gets or sets an object that chooses a toolbar item style based on custom logic. This is a dependency property.

Namespace: DevExpress.Xpf.Core

Assembly: DevExpress.Xpf.Core.v24.2.dll

NuGet Package: DevExpress.Wpf.Core

#Declaration

public StyleSelector ToolbarItemContainerStyleSelector { get; set; }

#Property Value

Type Description
StyleSelector

A StyleSelector descendant that chooses a style based on custom logic.

#Remarks

The ThemedWindow.ToolbarItemContainerStyle property defines the toolbar items’ style. If you have more than one style that can be used to render property descriptions, you can implement custom logic to choose the required style. To do this, derive from the StyleSelector class, implement the SelectStyle method that returns the style which meets the required condition, and assign it to the ToolbarItemContainerStyleSelector property.

If both the ThemedWindow.ToolbarItemContainerStyle and ToolbarItemContainerStyleSelector are specified, a property description is rendered using the style returned by the style selector. If the template selector returns null, a Toolbar item uses the style specified by the ThemedWindow.ToolbarItemContainerStyle property.

The following code sample shows how to use the ToolbarItemContainerStyleSelector:

 public class SampleStyleSelector : StyleSelector {
      public override Style SelectStyle(object item, DependencyObject container) {
          if(item is TextEdit) {                
              return (container as FrameworkElement).TryFindResource("editorStyle") as Style;
          }
          if(item is HeaderItemControl && (item as HeaderItemControl).Tag != null && (item as HeaderItemControl).Tag.ToString() == "bordered") {                
              return (container as FrameworkElement).TryFindResource("borderedHeaderItemStyle") as Style;
          }
          return base.SelectStyle(item, container);
      }
  }

The image below illustrates the result:

Refer to the Styles and Templates topic for more information.

See Also