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

Change task backgroud in the themes

6 Answers 122 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
Jacky
Top achievements
Rank 1
Jacky asked on 10 Jan 2017, 07:03 PM

Currently I'm using the themes Visualstudio2013 for gantt view. 

I only want to change background in one case and others would like to normal in the themes .

I found the sample "Tasks with different color" in the SDK.  But the sample didn't work well. the fonts color , progress bar color are reset.

 Any suggestion for this situation?

 

Thanks

-Jacky

6 Answers, 1 is accepted

Sort by
0
Lance | Senior Manager Technical Support
Telerik team
answered on 11 Jan 2017, 11:45 PM
Hello Jacky,

This documentation explains the styles and templates of the RadGanttView.  

For a tutorial on how to style just the task (which is the "Event" part), you can review the first example in the Examples section of that page. The example changes the background of the event to Navy blue.

For your convenience, here's the snippet:

<Style TargetType="telerik:EventContainer" BasedOn="{StaticResource EventContainerStyle}">
    <Setter Property="Foreground" Value="White" />
    <Setter Property="Background" Value="Navy" />
</Style>

You want to also make sure you're using the UI for WPF Implicit Styling approach for this to work correctly.

Please let us know if you have any further trouble.

Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Jacky
Top achievements
Rank 1
answered on 12 Jan 2017, 11:38 PM

Hi Lance,

The situation is that I only want to change one task background.

Can I have something like : CustomTask.Background = Brushes.Gray.  and if I am not set it, the others still want to keep the color in themes.

Thanks,

 

 

0
Jacky
Top achievements
Rank 1
answered on 13 Jan 2017, 12:18 AM

I don't know how to create " EventContainerStyle" from themes Visualstudio2013.

"EventContainerStyle" should be the default style

but it can not be recognized when I use :

<telerik:RadGanttView.Resources>
<Style TargetType="telerik:EventContainer" BasedOn="{StaticResource EventContainerStyle}">
<Setter Property="Background" Value="{Binding OriginalEvent.Background}" />
</Style>

</telerik:RadGanttView.Resources>

 

can you give me a sample project ? thanks.

0
Jacky
Top achievements
Rank 1
answered on 13 Jan 2017, 02:42 AM

Ok, I can run application now. Thanks.

0
Jacky
Top achievements
Rank 1
answered on 13 Jan 2017, 05:28 PM

the problem is when you select the event, the background is still not right.

How can I set background when the event in selected state ?

 

0
Lance | Senior Manager Technical Support
Telerik team
answered on 20 Jan 2017, 11:31 PM
Hello Jacky,

For this, you'll need to edit the control template of the EventContainerTemplate and edit the selected visual state.

You can find the template on line 824 in Telerik.Windows.Controls.GanttView.xaml ResourceDictionary (if you're not familiar with using the Implicit styles from a XAML file instead of the theme's DLL, see here for instructions).

Alternatively, if you want to keep using the Theme DLL, you can copy out the template and add it to your app. For your convenience, I have included the entire template in the attached demo.

To keep this as simple as possible and not change any of the control's parts, I just added an animation to the Selected VisualState... so that if selection occurs, change the Rectange named "Background" to use my custom brush for it's Fill property.

Here's a screenshot:




I've attached a demo, go to App.xaml to see the style and template. You can find the added animation on line 67.

Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GanttView
Asked by
Jacky
Top achievements
Rank 1
Answers by
Lance | Senior Manager Technical Support
Telerik team
Jacky
Top achievements
Rank 1
Share this question
or