Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
165
ConditionalFormatting with UnboundColumns
posted

The ItemsSource of my Grid is a IEnumerable<SampleObject>.

The SampleObject consist of Guid id, String str1, String str2 and a ObservableCollection<SampleDynObject> dy.

The SampleDynObject consist of one strTest property.

After the creation of the xamWebGrid, I create TextColumns for the id, str1 and str2 data.

For the data from the SampleDynObject, I create UnboundColumns 

UnboundColumn col = new UnboundColumn() { Key = Guid.NewGuid().ToString(), ValueConverter = new SampleConverter(), ValueConverterParameter = i }; 

The SampleConverter looks like this:

    public class SampleConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            SampleObject so  = value as SampleObject;
            int index = Int32.Parse(parameter.ToString()); //This is the index of the SampleObject's child collection
            if (so != null)
            {
                return so.dy[index].strTest;
            }
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

The question is: I tried to use the ContainingConditionalFormatRule, but it worked only on the TextColumns and not on the UnboundColumns.
My idea was to manually check the Rule by adding a second ValueConverter, but it seems to be only possible in the XAML-Markup and not by code.
So, how can I format the Background of the Cells.

Parents Reply Children