I am working with Wpf. I am using TabControl, In some specific condition TabItem’s Header contains ‘*’ symbol. I need to write a trigger so that whenever there is any such content in the Header, TabItem’s Background changes. I am not able to find a way to do this in xaml. Any help plz.
I am working with Wpf. I am using TabControl, In some specific condition TabItem’s
Share
If I understand your question correctly, I think you’re having the same fundamental problem as the person who asked this question: WPF Trigger when property value is greater than a certain amount which unfortunately just links to another forum post: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/a8ad8c14-95aa-4ed4-b806-d0ae874a8d26/ but I will summarize it here:
If you use a DataTrigger, instead of a regular trigger, and bind to the Header Text you can run the value through an IValueConverter, which will let you convert your string into a boolean True/False value based on whether it has an asterisk or not.
Note that my example sets the foreground, because the tab item style seems to override the background value and this still answers the original question.