Saturday, 15 January 2011

xaml - How to redefine FocusVisualStyle for a WPF user control -


I am trying to redefine FocusVisualStyle for user control (webexes it To make it more clear) and this is not working I just can not slap

  & lt; Style x: key = "{x: Static System Parameter. Focus Violet Style =" "TargetType =" Control "& gt; & lt; Setter Property =" Control " Template "> Setter.Value> gt; ControlTemplate & gt; Rectangle margin =" 3 "stroke light =" 2 "stroke =" red "snaptwoVideo pixel =" true "/> & Lt; / controlTemplate & gt; & lt; /Setter.Value>)?lt; / center & gt; & gt; Style / gt; & gt; Style Target Type = "Control" & gt; & lt; Setter Property = "Focus visual style" value = "{dynamic resource {x: static system parameter. FocusVisual Staleke}} "/> & lt; / style & gt;  

In my code ( UserControl.Resources )? Although it does not work

This works when I explicitly set the focus view style on a particular control:

  & lt; radio button group name = " RBGUP "TabIndex =" 30 "Focus Violet Style =" {Static Resources {x: Static SystemPamers.FocusVisual Stalek}} "& gt; Option A & lt; / Radio Button & gt;  

What am i

To be automatically selected for style first, TargetType should be similar to the actual control type you intend to apply to, so, Change the radio button's target from the control .

second,

The default template RadioButton, FocusVisualStyle set ControlTemplate triggered, whatever value you set in Style Setters, it will be overridden by triggering thumbnail control . And since there is a higher priority than the control of the local value, the template is triggered, so it needs to be set locally.


There are two potential solutions -

First - either place the Override Full Control Cell of Control button and place your focus visual style there.

Second - The style trigger is a high priority sequence from the control template triggers, triggers in focus style style and it's overridden something like this:

  & lt; Style x: key = "{x: static system parameter. Focus visual stalekey}" & gt; & Lt; Setter Property = "Control. Template" & gt; & Lt; Setter.Value & gt; & Lt; ControlTemplate & gt; & Lt; Rectangle margin = "- 3" stroke light = "2" stroke = "red" snaptwoVideo pixel = "true" /> & lt; / ControlTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt; & Lt; Style target type = "radio button" xmlns: sys = "clr-namespace: system; assembly = mscoreib" & gt; & Lt; Style.Triggers & gt; & Lt; Data Trigger Binding = "{Binding Source = {x: Static System: Boolean. TrueString}}" Value = "True" & gt; & Lt; Setter Property = "FocusVijual Style" value = "{Static Resources (x: Static SystemPamatators.focusual Stalekei}}" /> & gt; & gt; DataTrigger & gt; & lt; /Style.Triggers> & lt; / style & Gt;  

No comments:

Post a Comment