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

No colors...

5 Answers 51 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Pavel Ruslanovich Kovyev
Top achievements
Rank 1
Pavel Ruslanovich Kovyev asked on 05 Jul 2010, 08:53 AM
Добрый день.
У меня класс:
public class Person
{
public string Name { get; set;}
public Brush MyColor { get; set; }
}
Делаю коллекцию. Делаю Binding к гриду:
<telerikGrid:RadGridView ItemsSource="{Binding Persons}">
                <telerikGrid:RadGridView.Columns>
                    <telerikGrid:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Name" Background="{Binding MyColor}"/>
                </telerikGrid:RadGridView.Columns>
            </telerikGrid:RadGridView>
Имя меняется, а цвет нет. Хотя если задаю цвет вручную Background="Blue", то все окрашивается нормально.
В чем может быть дело?


Good day.
I have class:
public class Person
{
public string Name { get; set;}
public Brush MyColor { get; set; }
}
I have collection by this class. I do Binding:
<telerikGrid:RadGridView ItemsSource="{Binding Persons}">
                <telerikGrid:RadGridView.Columns>
                    <telerikGrid:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Name" Background="{Binding MyColor}"/>
                </telerikGrid:RadGridView.Columns>
            </telerikGrid:RadGridView>
Name change, but no color. Although if you set the color manually Background = "Blue", then all painted normally.
What could be wrong?

5 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 05 Jul 2010, 09:14 AM
Hello Pavel Ruslanovich Kovyev,

From your code , I understand you are trying to set different color to each cell depending on a value.
To achieve this , you need to set the binding at cell level , such as :
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" >
                    <telerik:GridViewDataColumn.CellStyle>
                        <Style TargetType="telerik:GridViewCell">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate>
                                        <Border Background="{Binding MyColor}">
                                            <TextBlock Text="{Binding Name}" />
                                        </Border>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </telerik:GridViewDataColumn.CellStyle>
                </telerik:GridViewDataColumn>


Greetings,
Pavel Pavlov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Pavel Ruslanovich Kovyev
Top achievements
Rank 1
answered on 05 Jul 2010, 11:45 AM
 xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
......



Error 2 Type 'telerikGrid:GridViewCell' was not found. D:\Projects\Silverlight\MyProjects\ScoutWeb\LightWeb\View\SpisokAvtoView.xaml 44 29 LightWeb

0
Pavel Pavlov
Telerik team
answered on 05 Jul 2010, 11:57 AM
Hi Pavel Ruslanovich Kovyev,

GridViewCell is located  in the Telerik.Windows.Controls.GridView namespace.

Sincerely yours,
Pavel Pavlov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Pavel Ruslanovich Kovyev
Top achievements
Rank 1
answered on 06 Jul 2010, 04:42 AM
xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"  - It is. What else is needed?
0
Vlad
Telerik team
answered on 06 Jul 2010, 06:25 AM
Hi,

 You do not need anything else! Furthermore If your application is Silverlight 4 you can use directly our URI namespace instead.

Best wishes,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Pavel Ruslanovich Kovyev
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Pavel Ruslanovich Kovyev
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or