wpf - How to set a global style to XAML buttons that have exisiting control templates -


I am trying to create a global style so that the mouse cursor will turn into one hand when the mouseover is the app on any button. However, my button has its own control templates that use the Ismouthover trigger, so my global ismassover trigger is not working. & lt; Style Target Type =

"{X: Type Button}" & gt; & Lt; Style.Triggers & gt; & Lt; Trigger Property = "Ismouth Over" Value = "True" & gt; & Lt; Setter property = "cursor" value = "arm" /> & Lt; / Catalyst & gt; & Lt; /Style.Triggers> & Lt; / Style & gt;

And here's a button:

  style x: key = "VideoVolumeButtonBaseStyle" TargetType = "{x: Type Button}" & gt; & Lt; Setter property = "horizontal content alignment" value = "center" /> & Lt; Setter Property = "Vertical Content Element" Value = "Center" /> & Lt; Setter property = "foreground" value = "{static resistor default collar brush}" /> & Lt; Setter property = "padding" value = "1" /> & Lt; Setter property = "height" value = "27" /> & Lt; Setter property = "width" value = "31" /> & Lt; Setter Estates = "Template" & gt; & Lt; Setter.Value & gt; & Lt; ControlTemplate TargetType = "{x: type button}" & gt; & Lt; Border x: name = "content border" cornerreadia = "3" background = "transparent" borderbrush = "transparent" bordertyxide = "2" & gt; & Lt; StackPanel Orientation = "Horizontal" Horizontal Alignment = "Left" & gt; & Lt; ContentPresenter Name = "contentPresenter" content = "{TemplateBinding content}" workspaceElement = "center" horizontal align = "left" /> & Lt; / StackPanel & gt; & Lt; / Border & gt; & Lt; ControlTemplate.Triggers & gt; & Lt; Trigger Property = "IsDefaulted" Value = "true" /> & Lt; Trigger Property = "Ismaas Over" Value = "True" & gt; & Lt; Setter property = "foreground" value = "{static resource focused collar brush}" /> & Lt; / Catalyst & gt; & Lt; Trigger Property = "Issued" value = "True" & gt; & Lt; Setter property = "foreground" value = "{static resource focused collar brush}" /> & Lt; Setter Property = "Margin" Value = "1, -2,0,0" TargetName = "Content Presentation" /> & Lt; / Catalyst & gt; & Lt; Trigger Property = "Iceded" value = "wrong" & gt; & Lt; Setter property = "foreground" value = "{static resource disabled collar brush}" /> & Lt; / Catalyst & gt; & Lt; /ControlTemplate.Triggers> & Lt; / ControlTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt;    

You can see your later style your global On Style

  & lt; Style x: key = "GlobalStyle" TargetType = "{x: Type Button}" & gt; & Lt; Style.Triggers & gt; & Lt; Trigger Property = "Ismouth Over" Value = "True" & gt; & Lt; Setter property = "cursor" value = "arm" /> & Lt; / Catalyst & gt; & Lt; /Style.Triggers> & Lt; / Style & gt; & Lt; Style x: Key = "ButtonStyle" TargetType = "{x: Type Button}" based on = "{StaticResource GlobalStyle}" & gt; ... & lt; Setter Estates = "Template" & gt; & Lt; Setter.Value & gt; & Lt; ControlTemplate TargetType = "{x: type button}" & gt; ... & lt; / ControlTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt;   

If you do not want to name your global style , then you can base it on the named style : < / P>

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -