views:

33

answers:

1

This is a silverlight/XAML question.

Not sure what I'm doing wrong, this seems to throw an error:

<ColorAnimation 
Storyboard.TargetName="btnRemoveBorder" 
Storyboard.TargetProperty="Background" 
To="#FFDEBA29" 
Duration="0" />

2nd question is... rather confused with the Selected and Focused states. Can one state take precedence over another?

A: 

Background is not a Color but instead a Brush which is why it can't be animated directly with a ColorAnimation. Instead try the following.

<ColorAnimation 
    Storyboard.TargetName="btnRemoveBorder" 
    Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" 
    To="#FFDEBA29" 
    Duration="0" />

With regard to the VisualStateManager question, one state from each state group can be active. So in the case of a Button for example, it can be in both the Focused and Pressed state. For this reason, you should try to design your states and control templates in such a way that does not depend on which state becomes active first. Usually this means you shouldn't animate the same element/property in two different state groups. But technically speaking, there's nothing preventing you from doing so. Whichever state the control goes to last (using the VisualStateManager.GoToState method) will take precedence.

Josh Einstein
Great 1st answer! For the 2nd question, I'm trying to get a selected state to not be affected by the hover state (both are quite commonly used and usually different). Thinking css here would be quite easy... but how to do this in xaml?
Brandon
What control are we talking about?
Josh Einstein
The border control. I want the selected state to be fixed and unchangeable from hover...
Brandon
I don't believe that has a Selected state. If you're talking about your own custom control you could just make the selected/mouseover states mutually exclusive. Otherwise you should design your control template to have a template part (such as a rectangle) that is visible on Selected and obscures the other element that is visible on MouseOver. So that way your "selected" part always hides the "mouseover" part.
Josh Einstein
Good idea, thanks.
Brandon