Hello,
I have the following XAML and the BackgroundActive property in my ViewModel gets read, but doesn't seem to get set in the datagrid. If I hardcode a brush color to the BackgroundActive value, it displays as it should. Any help much appreciated.
<igDP:XamDataGrid Name="DocumentsGrid" DataSource="{Binding Documents}" ActiveDataItem="{Binding SelectedRow}" RecordLoadMode="{Binding GridRecordLoadMode, Mode=OneTime}" RecordContainerGenerationMode="{Binding ContainerGenerationMode, Mode=OneTime}">
<igDP:XamDataGrid.Resources>
<Style TargetType="{x:Type igDP:DataRecordCellArea}">
<Setter Property="BackgroundActive" Value="{Binding DataContext.ActiveGridRowColor, ElementName=DocumentsGrid, Mode=OneWay}"/>
</Style>
</igDP:XamDataGrid.Resources>
<igDP:XamDataGrid.FieldSettings>
<igDP:FieldSettings AllowEdit="False" />
</igDP:XamDataGrid.FieldSettings>
</igDP:XamDataGrid>
Well, actually there is! If you are willing to wrap your data source in a CollectionView class, you can use the IsSynchronizedWithCurrentItem property in the XamDataGrid (orXamDataPresenter). The CollectionClass CurrentItem is the property that will represent the selected item from the grid.
I've attached a sample I already had that demonstrates this feature. The sample uses XamDataPresenter. However, it works with XamDataGrid as well.
And I'm still working on the Brush example.
I think I figured it out, although I don't like having to injecf the xamDatagrid into my ViewModel, but I'm basically doing GetValue when my SelectedRow is being set through the Grid, then in there I'm reading the injected grid's ActiveRecord index.
For setting the active record, I'm doing the reverse by using SetValue.... I wish there was a more elegant way for this...something like a bindable "SelectedRowIndex" property on the xamDataGrid itself would be fantastic :)
This may be a bit off topic, but how do I get and set the selected row's index through binding? I can't seem to figure it out and I basically pass the xamDatagrid into my ViewModel, but I still cant seem to get/set the selected row's index...
ActiveBackground only affects the active cell. There is another property for highlighting the entire row. I will finish that sample and post it for you. My sample colorizizes active cells and entire row backgrounds.
ah, didn't notice that :) I changed it to CellValuePresenter, but now only the cell gets colored the way I wanted as opposed to the whole row. I want the whole active row to be colored. Also, the property still gets read multiple times, it'd be nice if there was a way to just read that property once. Progress is good though!