triggers - WPF Label IsMouseOver style doesn't work after click -


My UI has a label and there is a style for it.

  & lt; Style x: key = "change color label" target type = "{x: type label}" & gt; & Lt; Setter property = "font size" value = "13" & gt; & Lt; / Setter & gt; & Lt; Setter Property = "Foreground" Value = "# FF 676767" & gt; & Lt; / Setter & gt; & Lt; Setter property = "background" value = "white" & gt; & Lt; / Setter & gt; & Lt; Style.Triggers & gt; & Lt; Trigger Property = "Ismouth Over" Value = "True" & gt; & Lt; Setter property = "background" value = "# FFEIEEEE" & gt; & Lt; / Setter & gt; & Lt; Setter property = "foreground" value = "#ff 20067b0" & gt; & Lt; / Setter & gt; & Lt; / Catalyst & gt; & Lt; /Style.Triggers> & Lt; / Style & gt;   

Also mouseover trigger I do not wants to set the same property values ​​when you click the label would (as click event label, I Mausdaun I use the event). Here Mausdaun event code

  private void myLabel_MouseDown (object sender, MouseButtonEventArgs e) {myLabel.Foreground = new SolidColorBrush (Color.FromArgb (0xff, 0x00, 0x67, 0xB0 )); MyLabel.Background = New SolidColorBrush (Color.FromArgb (0xff, 0xea, 0xec, 0xee)); }  

So my problem is that if I mouse over my label, then my mouseover style is never applied to my label. I know about overriding style I do not know about getting rid of it.

Your Mausdaun handler Foreground and bACKGROUND a place value has been set, and local values ​​on Msdian for more information, including a priority over all other price sources, sets determined by triggers and Setters See.

Use SetCurrentValue to change the current property value without switching to local values:

  myLabel.SetCurrentValue (Control.ForegroundProperty, SolidColorBrush (Color.FromArgb (0xff, 0x00, 0x67, 0xB0)));   

Alternatively, apply a custom style to myLabel to replace foreground and background Uses the trigger, and get rid of the event handler completely.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -