How do I change the style of the textbox in the textbox style data trigger?

I've created a default style for my textbox controls, but I would like to be able to change the style at runtime.

I have a property that I want to bind to this informs the UI if the data is required or not, and I want to be able to change the style of the textbox to a different style that displays a red line below the textbox. I cannot use this in the standard textbox style I created because the property for each textbox is different, i.e. IsEmailMandatory, isNameMandatory.

I was trying to bind a textbox style data trigger for every textbox I have, but I get a message that I cannot change the style in the style. so how to do it?

+1


a source to share


1 answer


You don't need to change the entire style in the trigger, just the template.



Another way to achieve something like this is to use the attached properties. Assuming the IsEmailMandatory, isNameMandatory properties are in the DataContext and not the control itself, you can bind the value you want to the attached property and then run it in your default style.

0


a source







All Articles