I have read this post: http://xceed.com/CS/forums/post/7583.aspx and tried it on my grid.
I have an ID column, which is sometime -1. My DataContext class has an ObservableCollection<> called LotList.
LotList has a property ACISLotId.
- LotListViewModel (DataContext for the page)
When using the following code:
<xcdg:DataGridControl ItemsSource="{Binding Path=LotList}" .....
.........
<xcdg:DataGridControl.Resources>
<Style TargetType="{x:Type xcdg:DataRow}">
<Style.Triggers>
<!-- Currently spitting out errors but is working.-->
<DataTrigger Binding="{Binding Path=ACISLotId}"
Value="-1">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="BurlyWood"/>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</xcdg:DataGridControl.Resources>
........
<xcdg:DataGridControl.Columns >
<xcdg:Column FieldName="ACISLotId" Title="Id" Visible="False" />
........
I get the following error:
BindingExpression path error: 'ACISLotId' property not found on 'object' ''LotListViewModel' (HashCode=17792110)'. BindingExpression:Path=ACISLotId; DataItem='LotListViewModel' (HashCode=17792110); target element is 'DataRow' (Name=''); target property is 'NoTarget' (type 'Object')
So, from this - its thinking ACISLotId is on the DataContext root, but in fact its lower on the tree:
I'm not sure how to bind the trigger correctly.
Note that the above code DOES WORK, but it spits out an exception (above) for every line of the grid, which consumes resources and makes it really slow.
How can i fix this so it stops throwing exceptions?
And if you have an answer, could you please supplement it with why this binding works AND throws an exception? I thought bindings - if they didn't find what they are looking for at the current level would go UP the tree.. not down it.
Thanks
Brett