I know I can rewrite the Template of my TextBoxes to redefine it's visual states but isn't there an easy way to just say: "make this textbox yellow when it is active (got focus)"?
Something like "input:active" in css.
Maybe a way in silverlight to set the style to a visual state of开发者_StackOverflow a control instead of it's general look?
Thanks
You should make a Style
which changes the VisualState
.
See here: http://msdn.microsoft.com/en-us/library/ms752068.aspx
If you dont want to use VisualStates you can simply set a FocusVisualStyle directly on the TextBox.
<TextBox FocusVisualStyle={...} ... />
Or you can use a trigger in the normal style. In fact the documentation above suggests using a trigger can be a better approach:
If you are intending control-specific behavior that is deliberately not coherent across a theme, a much better approach is to use triggers in styles for individual input state properties, such as IsFocused or IsKeyboardFocusWithin,
A trigger is the closest thing to the css pseudo-class approach, unfortunately its not as succinct.
精彩评论