Click here to Skip to main content
15,041,525 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have a trigger:

    <DataTrigger Binding="{Binding Path=JOB_NUMBER}" Value="*MVR*">
        <Setter Property="Foreground" Value="Red"></Setter>

If the PRODUCT_NAME = "L" then the foreground color will be red. That is okay.

How can I use this trigger, if not equal but contains this value.

For ex.:


Cells must have red.

Is there some kind of replacement character? %L%?

Could you offer some solution?

I have been looking for solution for a long time...

Thank you!

In all more complex cases when binding of the dependency property to some other properties is not enough, such as in case of taking some conditions into account, you have to trigger the property modification in code behind, which is as trivial as just using the property as it is usually used in code, in response to the event you need to handle.

A so-called value converter might help you.
Please have a look here:[^]
In the Convert method you must return 'L' if value contains 'L'
using System;
using System.Windows.Data;

namespace SharepointWebServiceTest
    class LConverter : IValueConverter
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
                return "L";
                return value; 

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            throw new NotImplementedException();
vrobi88 9-Mar-15 8:48am
Thank you Guys!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900