Hi,
I am trying to use RowStyleSelector with a RadGridView having an ItemsSource of type ObservableCollection<T>. The RowStyleSelector looks at the value of a property of T to set the background color of the corresponding row.
My problem is that the items may be altered outside of the grid. The new values are immediately picked up by the cells of the grid (because of the ObservableCollection and because T implements INotifyPropertyChanged), but the row style is not updated accordingly. However, if I sort the grid by clicking on one of the columns, the row styles are updated.
How can I ensure that the style is updated as soon as the values of the cells are updated?
In case it matters, this is how the RadGridView is declared (stripped down a bit):
This is the RowStyleSelector (stripped down a bit):
And this is the Style (stripped down a b
Best regards
Linus
I am trying to use RowStyleSelector with a RadGridView having an ItemsSource of type ObservableCollection<T>. The RowStyleSelector looks at the value of a property of T to set the background color of the corresponding row.
My problem is that the items may be altered outside of the grid. The new values are immediately picked up by the cells of the grid (because of the ObservableCollection and because T implements INotifyPropertyChanged), but the row style is not updated accordingly. However, if I sort the grid by clicking on one of the columns, the row styles are updated.
How can I ensure that the style is updated as soon as the values of the cells are updated?
In case it matters, this is how the RadGridView is declared (stripped down a bit):
<
telerik:RadGridView
Name
=
"DocumentGrid"
SelectionMode
=
"Extended"
ItemsSource
=
"{Binding Path=Documents}"
AutoGenerateColumns
=
"False"
IsReadOnly
=
"True"
RowStyleSelector
=
"{StaticResource DocumentStyleSelector}"
>
This is the RowStyleSelector (stripped down a bit):
internal
class
DocumentStyleSelector : StyleSelector
{
public
Style DocumentModifiedStyle {
get
;
set
; }
public
override
Style SelectStyle(
object
item, DependencyObject container)
{
var document = item
as
Document;
if
(document !=
null
&& document.EntityState == EntityState.Modified)
{
return
DocumentModifiedStyle;
}
return
null
;
}
}
And this is the Style (stripped down a b
<
layout:DocumentStyleSelector
x:Key
=
"DocumentStyleSelector"
>
<
layout:DocumentStyleSelector.DocumentModifiedStyle
>
<
Style
TargetType
=
"telerik:GridViewRow"
>
<
Setter
Property
=
"Background"
Value
=
"DarkGray"
/>
</
Style
>
</
layout:DocumentStyleSelector.DocumentModifiedStyle
>
</
layout:DocumentStyleSelector
>
Best regards
Linus