Swatto

Swatto

  • NA
  • 23
  • 10.9k

Setting a style on a single element

Mar 21 2015 6:41 AM
Hello all,

I am trying to apply a style to a single element (in this case, context menu items) but it is not working, I can make the code work for the entire project but just not for the single ContextMenuItems that I want it to apply to:

Please could you tell me where I am going wrong - this code displays 'System.Windows.Style' in my context menu for some reason.

Thanks for any help

    <ContextMenu x:Key="SysTrayMenu">
        <Style TargetType="TextBlock">
            <Style.Triggers>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="TextDecorations" Value="Strikethrough"/>
                </Trigger>
            </Style.Triggers>
        </Style>
        <MenuItem Header="Show Window" Command="{Binding ShowWindowCommand}" />
        <MenuItem Header="Hide Window" Command="{Binding HideWindowCommand}"/>
        <MenuItem Header="Exit" Command="{Binding ExitApplicationCommand}" />
    </ContextMenu>

Answers (2)