SEAN
SEAN

Reputation: 3

WPF C# change resource dictionary accent color in code

i have a TextBox enter image description here The textbox highlights when selected, & uses the accent color from the resource dictionary in app.xaml

                <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Green.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />

& if the username is less than 8 characters i'd like the accent color to turn to red, is there any way of doing this?

Upvotes: 0

Views: 258

Answers (2)

T.Schwarz
T.Schwarz

Reputation: 140

You'll have to overwrite the template for that textbox locally to add a datatrigger that triggers on a IValueConverter. Without seeing the template in question i can't really be more specific as we can't know how the accent is set up.
Further reading:

Upvotes: 1

Forrest Lowe
Forrest Lowe

Reputation: 21

I'm not sure your explanation is clear on what your question is.. From what I understand you're asking how you would change the color of the text if it's less than 8 characters? If that's your question then 'string.Length' should suffice.

Upvotes: 0

Related Questions