1. In code behind, setting theme the application:
StyleManager.ApplicationTheme = new MetroTheme();
2. Setting the theme in the xaml:
<
telerik:RadGanttView
x:Name
=
"radTP"
telerik:StyleManager.Theme
=
"Metro"
Grid.Row
=
"0"
Grid.Column
=
"1"
>
<
telerik:RadGanttView.Columns
>
<
telerik:TreeColumnDefinition
Header
=
"Title"
/>
<
telerik:ColumnDefinition
MemberBinding
=
"{Binding Start}"
Header
=
"Start"
ColumnWidth
=
"180"
/>
<
telerik:ColumnDefinition
MemberBinding
=
"{Binding End}"
Header
=
"End"
ColumnWidth
=
"180"
/>
</
telerik:RadGanttView.Columns
>
</
telerik:RadGanttView
>
3. Setting the theme on the control via the code behind:
StyleManager.SetTheme( radTP, new MetroTheme() );
Is there something different for GanttView, or is it simply not supporting themes?
14 Answers, 1 is accepted
To set a theme of RadGanttView, please add the attached file to your project.
After that all you have to do is to add it as a resource dictionary to your page as it is shown here.
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Generic_Metro.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Kind regards,
Rosi
the Telerik team
After adding the resourcedictionary, I'm unable to compile, because of the following error in the Generic_Metro.xaml:
The tag 'ProgressPresenter' does not exist in XML namespace 'http://schemas.telerik.com/2008/xaml/presentation'.
What assembly should I add to help it find it?
Please try the following way for applying Metro theme. If this does not work for you,please specify the exact version of binaries that you use.
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Telerik.Windows.Controls.GanttView;component/Themes/Generic_Metro.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Scheduling.Core;component/Themes/Generic_Metro.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
All the best,
Rosi
the Telerik team
Thanks for sending this again, but that wasn't really the problem. I've added that prior, although I noticed before the reference to Scheduling.Core wasn't included in the ResourceDictionary XAML. The problem has to do with the Generic_Metro.xaml page, which is where I'm getting the error (line 493 of the original xaml file):
<
telerik:ProgressPresenter
VerticalAlignment
=
"Bottom"
Height
=
"2"
Margin
=
"0 0 0 2"
HorizontalAlignment
=
"Stretch"
Progress
=
"{Binding Progress}"
Orientation
=
"Horizontal"
>
<
Rectangle
Fill
=
"{StaticResource MainBrush}"
Opacity
=
"0.7"
VerticalAlignment
=
"Stretch"
HorizontalAlignment
=
"Stretch"
/>
</
telerik:ProgressPresenter
>
And the error I'm getting is
The tag 'ProgressPresenter' does not exist in XML namespace 'http://schemas.telerik.com/2008/xaml/presentation'.
I'm running the Q1 2012 build, using Silverlight 5.
Please find attached a project illustrating how to apply a Metro theme that works as expected at our side.
Kind regards,
Rosi
the Telerik team
We are sorry for the inconvenience caused. The problem will be fixed with our SP build that will be available for download by the end of the week.
Regards,
Rosi
the Telerik team
Hopefully I am just overlooking an obvious issue as it appears the demo is running off a later build than the production release (i.e. the popup issue with controls is now fixed from the first hotfix).
I am unable to upload the project, but here are key files:
MainPage.xaml.cs
<
UserControl
x:Class
=
"SilverlightApplication8.MainPage"
mc:Ignorable
=
"d"
xmlns:local
=
"clr-namespace:SilverlightApplication8"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
d:DesignHeight
=
"300"
d:DesignWidth
=
"400"
>
<
Grid
>
<
Grid.Resources
>
<
ResourceDictionary
>
<
ResourceDictionary.MergedDictionaries
>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Controls.GanttView;component/Themes/Generic_Metro.xaml"
/>
<
ResourceDictionary
Source
=
"ScrollBarStyle.xaml"
/>
</
ResourceDictionary.MergedDictionaries
>
</
ResourceDictionary
>
</
Grid.Resources
>
<
Grid.DataContext
>
<
local:ViewModel
/>
</
Grid.DataContext
>
<
telerik:RadGanttView
TasksSource
=
"{Binding Tasks}"
VisibleRange
=
"{Binding VisibleRange}"
/>
</
Grid
>
</
UserControl
>
ViewModel.cs
namespace SilverlightApplication8
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Telerik.Windows.Controls.GanttView;
using Telerik.Windows.Controls.Scheduling;
using Telerik.Windows.Core;
public class ViewModel : PropertyChangedBase
{
public ViewModel()
{
var date = DateTime.Now;
var iterationTask = new GanttTask { Start = date, End = date.AddDays(2), Title = "First Iteration" };
var nextIterationTask = new GanttTask { Start = date.AddDays(7), End = date.AddDays(9), Title = "Second Iteration" };
var ganttAPI = new GanttTask { Start = date, End = date.AddHours(16), Title = "Design public API" };
var ganttDemos = new GanttTask { Start = date.AddHours(18), End = date.AddDays(1), Title = "Gantt Demos" };
var ganttRendering = new GanttTask { Start = date.AddDays(1).AddHours(5), End = date.AddDays(2), Title = "Gantt Rendering" };
var milestone = new GanttTask { Start = date.AddDays(2), End = date.AddDays(2).AddHours(1), Title = "Review", IsMilestone = true };
ganttAPI.SetRelations(new List<
Relation
> { new Relation { Task = ganttDemos } });
ganttDemos.SetRelations(new List<
Relation
> { new Relation { Task = ganttRendering } });
iterationTask.SetChildren(new ObservableCollection<
GanttTask
> { ganttAPI, ganttDemos, ganttRendering, milestone });
var gTasks = new ObservableCollection<
GanttTask
> {iterationTask, nextIterationTask};
Tasks = gTasks;
VisibleRange = new VisibleRange(date, date.AddDays(9));
}
private IEnumerable<
GanttTask
> tasks;
public IEnumerable<
GanttTask
> Tasks
{
get
{
return tasks;
}
set
{
tasks = value;
OnPropertyChanged(() => Tasks);
}
}
private VisibleRange visibleRange;
public VisibleRange VisibleRange
{
get
{
return visibleRange;
}
set
{
if (visibleRange == value) return;
visibleRange = value;
OnPropertyChanged(() => VisibleRange);
}
}
}
}
Also attached a screenshot of the directory structure. Please let me know if you need more information to reproduce the issue.
Thanks,
Philip
I know you keep saying this works but I cannot get it to work either. I am trying to do it all via XAML but keep getting the same error.
I have this has my resource XAML
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Telerik.Windows.Controls.GanttView;component/Generic_Metro.xaml" />
</ResourceDictionary.MergedDictionaries>
I have the file in the solution root set as a resource. I complie and get the following error.
Builds fine but at runtime throws an error of "Failed to assign to property 'System.Windows.ResourceDictionary.Source'. [Line: 13 Position: 44]"
if I do
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Generic_Metro.xaml" />
</ResourceDictionary.MergedDictionaries>
I get:
Object reference not set to an instance of an object. ... Generic_Metro.xaml 117 3
UPDATE: Actually got it work by adding the new ScrollBarStyle.xaml you provided in your example.
Could you please download the uploaded this week internal build (2012.1.0410) and try with it? I've also attached a simple project based on the provided code with trial assemblies for a reference.
Kind regards,
Yana
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thank you for your reply. I was able to get it to work, but I am not sure it is the proper way. I installed the latest patch (2012.1.0410) from the "Binaries" folder and it did not work. I tried from the "Binaries.NoXaml" folder and it really messed up my XAML display on the project... I was unable to use the application to get far enought to test it out.
I was able to get your sample project to work correctly (thank you very much for this). I noticed the Telerik.Windows.Controls.GanttView.dll in your project was from the "Binaries.NoXaml" folder (384K version). Since this is what was causing all the problems in the latest internal build under "Binaries", I took the "Binaries" build but replaced Telerik.Windows.Controls.GanttView.dll from the "Binaries.NoXaml" folder and everything seems to be working.
Can you tell me what the difference between the "Binary" and "Binary.NoXaml" dlls? Am I going to cause problems by mixing the dlls?
Thank you for your time,
Philip
Since Q1 SP1 we introduced a new way to style the controls using implicit styles. This is explained in details in the following help article:
http://www.telerik.com/help/silverlight/styling-apperance-implicit-styles-overview.html
So now we provide two folders with assemblies - the Binaries and Binaries.NoXaml. The second folder contains dlls with no xaml which can be used with implicit styles.
But note that at the moment RadGanttView has a different way of setting its styles as described in the previous posts. With the official Q2 release you will be able to style it only with implicit styles.
For now, you can use the dlls from both Binaries and Binaries.NoXaml folders without a problem.
Kind regards,
Yana
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thank you. I understand the direction you are going. Your help was most appreciated.
...Philip