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

Appending StaticResource styles to Telerik theme?

2 Answers 236 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Eric
Top achievements
Rank 1
Eric asked on 28 Oct 2011, 02:49 PM
Hi,

I'm having an issue with Q2 2010 Silverlight controls. I'm using the incredibly beautiful Windows 7 theme for my RadGridView, but there is some customization I'd like to add to my Grid. For example, I want the minimum height of my GridViewRows to be 30. This is how I thought I could tackle the issue:
<Style x:Key="GridViewRowStyle" TargetType="telerik:GridViewRow">
   <Setter Property="MinHeight" Value="30" />
</Style>


Truth be told, when I use RowStyle="{StaticResource GridViewRowStyle}" it sets my minimum row height to 30, but it gets rid of the custom theming to the control. I added <Setter Property="telerik:Styling.Theme" Value="Windows7" /> (or whatever the correct variant is, I got rid of it in my code so this goes by memory) and I was still getting an orange RowSelect color, instead of the default blue. Do I need to completely redefine the entire theme just to get a minium row size?

Another issue I was having was trying to set a UserResource for common occurances for each column. All of my columns share the following properties:
<Style x:Key="GridViewColumnStyle" x:TargetType="telerik:GridViewCell">
  <Setter Property="HeaderTextAlignment" Value="Center" />
  <Setter Property="IsCustomSortingEnabled" Value="True" />
  <Setter Property="IsReadOnly" Value="True" />
  <Setter Property="TextWrapping" Value="Wrap" />
</Style>

I can't figure out where to apply this. I've been trying <telerik:GridViewColumn CellStyle="{StaticResource GridViewColumnStyle}">  but that literally kills my Silverlight application.

Also, when I use <telerik:RadGridView Style={StaticResource ...} > it won't apply custom properties for RowIndicatorVisibility and CanUserFreezeColumns.

Let me also explain that this is my first real Silverlight project and I don't know the complexities and nuances of each Silverlight control. Is there anyway to do what I'd like to do with pure XAML, or am I going to need to do is programmatically? Thanks for any and all help.

2 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 29 Oct 2011, 11:18 AM
Hello Eric,

 

We are glad to hear that you like our Windows7 theme! Generally if you want to style any part of RadGridView in a theme different than the default one you should mark the style as based on the current theme, as shown below:


<Style x:Key="GridViewRowStyle" TargetType="telerik:GridViewRow" telerik:StyleManager.BasedOn="Windows7">
   <Setter Property="MinHeight" Value="30" />
</Style>


Otherwise it will return to the default one. The approach using a style setter is correct, however it is applicable in WPF not in Silverlight. In Silverlight you should use the one above. 
The same syntax is valid for any part of RadGridView. Regarding the issue will GridViewCell you are setting the properties which are not the properties of GridViewCell. By that reason the application crashes.
The style targeted at RadGridView is not applied, because it is not set as based on Windows7 theme.
Can you verify how this works for you? 



Regards,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Eric
Top achievements
Rank 1
answered on 31 Oct 2011, 03:50 PM
Thanks, it worked!

Is there anyway I can "package" a bunch of attributes like "CanUserFreezeColumns" into a resource that each RadGridViewColumn can use? I consider XAML messy as it is, and I would like to be able to clean up my code to use XXX="{StaticResource ColumnAttributes}" instead of having to manually add all those properties I listed in my first post. Partially because I'm a stickler like that, and partial because I want the code to be as clean and easy to read for the other members on my team.

Thanks,
Eric
Tags
GridView
Asked by
Eric
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Eric
Top achievements
Rank 1
Share this question
or