---
title: "Style triggers produce no effect"  
description: "Style triggers produce no effect"  
author: "Anonymous User"  
published: 2013-07-15  
updated: 2013-07-15  
canonical: https://www.mindstick.com/forum/1283/style-triggers-produce-no-effect  
category: "wpf"  
tags: ["wpf"]  
reading_time: 2 minutes  

---

# Style triggers produce no effect

Hello [MindStick](https://yourviews.mindstick.com/view/84668/how-mindstick-is-used-for-marketing-purposes)\

Every time I think I finally *get* `WPF/XAML` something unintuitive like this come up (rant over)...

I want to implement a "poor's man" [toggle](https://www.mindstick.com/forum/12682/jquery-toggle-if-statement) [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) for a [menu item](https://www.mindstick.com/forum/339/highlighting-the-menu-item). Essentially, when it's checked it should say "[Metric](https://www.mindstick.com/news/2295/more-people-need-to-monitor-this-crucial-metric-for-heart-health)" and when it's unchecked - "Imperial". I thought it should be fairly straightforward with `XAML`, but I can't get it to work.

Here's what I tried:

```
<MenuItem IsCheckable="True" IsChecked="True">
    <Style>
       <Style.Triggers>
           <Trigger Property="IsChecked" Value="True">
              <Setter Property="Header" Value="Metric"/>
           </Trigger>
           <Trigger Property="IsChecked" Value="False">
              <Setter Property="Header" Value="Imperial"/>
           </Trigger>
       </Style.Triggers>
     </Style>
</MenuItem>
```

It gives me an error "The member 'IsChecked' is not recognized or is not accssible" (same for [Header](https://www.mindstick.com/articles/336036/explain-about-html-header-body-and-footer-tags)).

The error goes away when I do `<Style
TargetType="{x:Type MenuItem}">`, but it doesn't do anything.

I tried directly without the `<Style>`

```
<MenuItem.Triggers>
   <Trigger...>
</MenuItem.Triggers>
```

First, it gave me the same error as above, but when I changed the [property](https://www.mindstick.com/blog/205/property-notification-in-c-sharp) to `Property="MenuItem.IsChecked"` it started screaming that only EventTriggers are allowed.

I also tried with a `DataTrigger` (granted, I still don't fully understand the [differences](https://www.mindstick.com/articles/12918/cat-5e-vs-cat-6a-understanding-the-major-differences) between the [triggers](https://www.mindstick.com/articles/337000/what-are-sql-triggers-and-ways-of-using-them-effectively)):

```
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type MenuItem}}, Path=IsChecked}" Value="True">
    <Setter Property="Header" Value="Metric"/>
</DataTrigger>
```

No effect.

Help... please...

Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)\

## Replies

### Reply by shreesh chandra shukla

Hey Babe Zaharias !

You have to assign the MenuItem's `Style` property by declaring the `<Style>` as child element of a `<MenuItem.Style>` element.

```
<MenuItem IsCheckable="True" IsChecked="True">
    <MenuItem.Style>
        <Style TargetType="MenuItem">
            <Style.Triggers>
                <Trigger Property="IsChecked" Value="True">
                    <Setter Property="Header" Value="Metric"/>
                </Trigger>
                <Trigger Property="IsChecked" Value="False">
                    <Setter Property="Header" Value="Imperial"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </MenuItem.Style>
</MenuItem>
```


---

Original Source: https://www.mindstick.com/forum/1283/style-triggers-produce-no-effect

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
