I am getting binding errors in the debug log when I use GroupRenderMode="Flat" with styles that depend on the ItemsSource item values. It looks as if each row is trying to bind to the RadGridView's DataContext in addition to the actual items. The style is applying correctly, the only difference I can see is the new errors in the debug log.
Below is a small example showing the problem. Note the binding error for every line in the grid:
System.Windows.Data Error: 40 : BindingExpression path error: 'IsComplete' property not found on 'object' ''MainWindow' (Name='')'. BindingExpression:Path=IsComplete; DataItem='MainWindow' (Name=''); target element is 'GridViewRow' (Name=''); target property is 'NoTarget' (type 'Object')
which does not occur if GroupRenderMode="Nested". It's trying to bind to MainWindow object instead of an Item.
Is this a bug or have I done something wrong somewhere?
Thanks,
Louis
Below is a small example showing the problem. Note the binding error for every line in the grid:
System.Windows.Data Error: 40 : BindingExpression path error: 'IsComplete' property not found on 'object' ''MainWindow' (Name='')'. BindingExpression:Path=IsComplete; DataItem='MainWindow' (Name=''); target element is 'GridViewRow' (Name=''); target property is 'NoTarget' (type 'Object')
which does not occur if GroupRenderMode="Nested". It's trying to bind to MainWindow object instead of an Item.
Is this a bug or have I done something wrong somewhere?
Thanks,
Louis
<
telerik:RadGridView
ItemsSource
=
"{Binding Path=Items}"
AutoGenerateColumns
=
"False"
GroupRenderMode
=
"Flat"
>
<
telerik:RadGridView.Resources
>
<
Style
TargetType
=
"{x:Type telerik:GridViewRow}"
>
<
Style.Triggers
>
<
DataTrigger
Binding
=
"{Binding Path=IsComplete}"
Value
=
"False"
>
<
Setter
Property
=
"Background"
Value
=
"Red"
/>
</
DataTrigger
>
</
Style.Triggers
>
</
Style
>
</
telerik:RadGridView.Resources
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
Header
=
"ItemName"
DataMemberBinding
=
"{Binding Path=ItemName}"
Width
=
"*"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
public
class
Item
{
public
string
ItemName {
get
;
set
; }
public
bool
IsComplete {
get
;
set
; }
}
public
partial
class
MainWindow : Window
{
public
ObservableCollection<Item> Items {
get
;
set
; }
public
MainWindow()
{
InitializeComponent();
Items =
new
ObservableCollection<Item>();
for
(
int
i = 0; i < 5; i++)
Items.Add(
new
Item()
{
ItemName =
"Object "
+ i,
IsComplete = (i % 2 == 1 ?
true
:
false
)
});
DataContext =
this
;
}
}