This is a migrated thread and some comments may be shown as answers.

GridViewCell foreground

1 Answer 47 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bhavin
Top achievements
Rank 1
Bhavin asked on 28 Oct 2009, 07:39 PM
I want to change foreground color of a column STATUS cell value  in a grid such that if STATUS=Available then text should appear in Green else in Red.I applied the style ,while debugging Convert method is debuggung sucessfully reading correct value but doesn't show up on grid.

 <Converter:DocumentColorConverter  x:Key="ConvertDocumentColor" />

                                                                            <Style TargetType="{x:Type telerik:GridViewCell}">
                                                                                <Setter Property="Foreground" Value="{Binding [STATUS], Converter={StaticResource ConvertDocumentColor}}" />
                                                                            </Style>
 public class DocumentColorConverter : IValueConverter
    {

        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            System.Windows.Media.Brush returnValue;
            string controlType = "";
            if (value != null)
                controlType = value.ToString();

            switch (controlType)
            {
                case "Available":
                    returnValue = Brushes.Green;
                    break;
                case "UnAvailable":
                    returnValue = Brushes.Red;
                    break;
                default:
                    returnValue = Brushes.Black;
                    break;

            }

            return returnValue;
        }

        #endregion

        #region IValueConverter Members


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

        #endregion
    }

1 Answer, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 29 Oct 2009, 02:01 PM
Hello bhavin patel,

You may find a working example for what you are trying to achieve in the following blog post:

http://blogs.telerik.com/pavelpavlov/posts/09-10-03/adding_additional_power_to_radgridview_for_silverlight_with_attached_behaviors.aspx

Let me know if you have further troubles implementing this into your project.

All the best,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Bhavin
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or