Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Code behind breaking trigger

$
0
0

Hi,

I have a usercontrol with a dependency property:

        public bool hit
        {
            get { return ( bool)GetValue(hitProperty); }
            set { SetValue(hitProperty, value); }
        }

        // Using a DependencyProperty as the backing store for hit.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty hitProperty =
            DependencyProperty.Register("hit", typeof( bool), typeof(note));

then I have a style on the usercontrol, that means when mouseOver, "hit" gets set to true, and when hit is true, the opacity changes.  All good

<UserControl.Style><Style><!--<Setter Property="local:note.hit" Value="False" />--><Setter Property="Grid.Opacity" Value=".1"/><Style.Triggers><Trigger Property="Grid.IsMouseOver" Value="True"><Setter Property="local:note.hit" Value="True"/></Trigger>                     <Trigger Property="local:note.hit" Value="True" ><Setter Property="Grid.Opacity" Value="1" /></Trigger>                      </Style.Triggers></Style></UserControl.Style>

Trouble is when I set "hit" to false from code behind I guess the style gets overwritten and the trigger no longer works.

How should I implement alternatively?

thanks

Z


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>