styling - In WPF, how do I prevent my style from being overridden? -
Please do not get caught in my example, just bear with me for the question:
my WPF application In, if I wanted to keep all the text boxes near the "green" background, then I can easily set it in my application. Resources.
& gt; Style target type = "text box" & gt; & Lt; Setter property = "background" value = "green" /> & Lt; / Style & gt;
This works Absolutely ... (Thanks WPF). However, if I had a text box somewhere, then I wanted to add add another style ... I > Example: That text box will be correctly red foreground when the mouse ends, but the green background is completely lost. So, the question is: How can I tell WPF not completely erase all the styling which came from above because only I have a simple, non-disputed, oh so little style Is that been added in a control somewhere? You can already get the overlapping styles using style "style" in the declaration. In your second style manifesto, try this: You can also base the style on a designated style,
& lt; Text box & gt; & Lt; TextBox.Style & gt; & Lt; Style & gt; & Lt; Style.Triggers & gt; & Lt; Trigger Property = "Textbox. Easous Overs" Value = "True" & gt; & Lt; Setter Property = "Text Box. Foreground" Value = "Red" /> & Lt; / Catalyst & gt; & Lt; /Style.Triggers> & Lt; / Style & gt; & Lt; /TextBox.Style> & Lt; / Text box & gt;
pre & lt; & Lt; TextBox.Style & gt; & Lt; Style based on = "{static resource {x: type text box}}" & gt; & Lt; Style.Triggers & gt; & Lt; Trigger Property = "Textbox. Easous Overs" Value = "True" & gt; & Lt; Setter Property = "Text Box. Foreground" Value = "Red" /> & Lt; / Catalyst & gt; & Lt; /Style.Triggers> & Lt; / Style & gt; & Lt; /TextBox.Style> & Lt; / Text box & gt;
& lt; Style x: key = MyNamedStyle & gt; & Lt; / Style & gt; & Lt; Style based on = "{static resource minet stella}" & gt; & Lt; / Style & gt;
Comments
Post a Comment