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

How to set the different EventContainer background color

1 Answer 73 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
zhu
Top achievements
Rank 1
zhu asked on 24 Apr 2019, 02:45 AM

Hi guys,

I Want to change the EventContainer background color by Progress Value

please tell me how to set How to set the different EventContainer background color

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 25 Apr 2019, 02:01 PM
Hi zhu,

You can set a different Background for the different tasks based on their Progress by defining a similar style:

<local:ProgressToBackgroundBrushConverter x:Key="ProgressToBackgroundBrushConverter" />
<Style TargetType="telerik:EventContainer">
    <Setter Property="Background" Value="{Binding OriginalEvent.Progress, Converter={StaticResource ProgressToBackgroundBrushConverter}}" />
</Style>

In the converter you can then determine what brushes to return based on the current progress:

public class ProgressToBackgroundBrushConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        var progress = double.Parse(value.ToString());
        if (progress < 20)
        {
            return Brushes.Red;
        }
 
        return Brushes.Green;
    }
 
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

I've prepared a small sample project to demonstrate this in action.

Please have a look and let me know if such an approach would work for you.

Regards,
Dilyan Traykov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GanttView
Asked by
zhu
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Share this question
or