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

How to set Style for all cells?

2 Answers 195 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 08 Apr 2013, 01:55 PM
How do you set the style for all cells in an autogenerated GridView in a designer friendly manner?

ItemContainerStyle has no effect.

it is possible to handle Columns.CollectionChanged and set Column.CellStyle there, but that approach requires code behind and is invisible at design time.

2 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 08 Apr 2013, 02:14 PM
Hello Martin,

 

As a rule of thumb if you want to apply a style to all cells in RadGridView you may define an implicit style targeted at GridViewCell, which will be applied to all cells in your grid. An implicit style is the one, which do not require to specify an x:Key attribute. Setting a cell style through the CellStyle property of the column requires a key and should be set manually to the columns you need. Since you need to have design time support the best option here is to define an implicit style in XAML, as shown below:

<Window
    x:Class="WpfApplication65.MainWindow"
    x:Name="Window"
    Title="MainWindow"
    Width="640" Height="480">
<Window.Resources>
    <Style TargetType="telerik:GridViewCell">
        <Setter Property="Background" Value="Red"/>
    </Style>
    </Window.Resources>
    <Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource SampleDataSource}}">
        <telerik:RadGridView  ItemsSource="{Binding Collection}"/>
    </Grid>
</Window>


Will you clarify how this works for you? 


All the best,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Martin
Top achievements
Rank 1
answered on 08 Apr 2013, 02:27 PM
That works, thanks.
Tags
GridView
Asked by
Martin
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Martin
Top achievements
Rank 1
Share this question
or