Live Chat Icon For mobile
Live Chat Icon

WPF FAQ

Find answers for the most frequently asked questions
Expand All Collapse All

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.

[XAML]

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

Permalink

Share with

Share on twitter
Share on facebook
Share on linkedin

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

Please submit your question and answer.