Change color of task dynamically
Hi,
i would like to change the color of a specific task with a button click, is it possible?
In order to obtain this result below.
Best regards
Gian Piero Truccolo
SIGN IN To post a reply.
3 Replies
SS
Sridevi Sivakumar
Syncfusion Team
June 30, 2021 11:27 AM UTC
Hi Gian Piero Truccolo,
Query: I would like to change the color of a specific task with a button click, is it possible
No, in Gantt control, we don’t support to change the specific task color dynamically, let us know if you need any further assistance.
Regards,
Sridevi S.
Query: I would like to change the color of a specific task with a button click, is it possible
No, in Gantt control, we don’t support to change the specific task color dynamically, let us know if you need any further assistance.
Regards,
Sridevi S.
GI
Gian
June 30, 2021 12:50 PM UTC
Hi,
does exist a workaround to reach this goal?
For example rigenerate l'itemsource?or something else?
Best regards
Gian Piero Truccolo
SS
Sridevi Sivakumar
Syncfusion Team
July 1, 2021 12:53 PM UTC
Hi Gian Piero Truccolo,
Query: does exist a workaround to reach this goal?
We have achieved your requirement at the sample level by customizing the node color dynamically as per the below code snippet.
In the below code snippet, we have added the Brush property to customize the node color
Query: does exist a workaround to reach this goal?
We have achieved your requirement at the sample level by customizing the node color dynamically as per the below code snippet.
In the below code snippet, we have added the Brush property to customize the node color
|
public class Task : NotificationObject
{
Brush nodeColor = (SolidColorBrush)new BrushConverter().ConvertFrom("#FF6BE6ED"
....
public Brush NodeColor {
get
{
return nodeColor;
}
set
{
nodeColor = value;
RaisePropertyChanged("NodeColor");
}
} .... |
We have customized the node template and binding the NodeColor property to the node border.
|
<Style TargetType="chart:GanttNode"
x:Key="TaskNode">
<Setter Property="HorizontalAlignment"
Value="Left" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="chart:GanttNode">
... <Border Name="PART_Border" Height="11"
Width="{TemplateBinding Width}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
SnapsToDevicePixels="True"
BorderThickness="0,0.4,0,0.4"
BorderBrush="Black"
Background="{Binding NodeColor}"> ....... |
Change the 1st node color when clicking the "Change color" button
|
private void TestButton_Click(object sender, RoutedEventArgs e)
{
(this.Gantt.ItemsSource as ObservableCollection<Task>)[0].ChildTask[0].NodeColor = (Brush)new BrushConverter().ConvertFromString(nodeColors[r.Next(0, 9)]);
} |
Screenshot:
Please have a sample from the below link
https://www.syncfusion.com/downloads/support/directtrac/general/ze/GanttSample-1991534926
Let us know if you need any further assistance.
Regards,
Sridevi S.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
GI Gian
- Jun 29, 2021 12:32 PM UTC
- Jul 1, 2021 12:53 PM UTC