Live Chat Icon For mobile
Live Chat Icon

How can I style a Separator used as a Menu Item ?

Platform: WPF| Category: Menu

Separator controls inside Menu elements appear differently from Separator controls outside a Menu. When you create a Menu with a Separator, the control automatically applies the Style identified by the SeparatorStyleKey property. Styles are placed in resource dictionaries and are searched for by their keys. To change the Style of a Separator inside a Menu, you must use the SeparatorStyleKey property to create your new Style.

The following example demonstrates this.


<Style x:Key='{x:Static MenuItem.SeparatorStyleKey}' TargetType='Separator'>
  <Setter Property='OverridesDefaultStyle' Value='true' />
  <Setter Property='Template'>
      <ControlTemplate TargetType='{x:Type Separator}'>
        <Border Width='30' Height='4' Margin='4' Background='Red'/>

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.