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>
If you notice, my sample XAML styled CellValuePresenter, not DataRecordCellArea. Let me know if this makes a difference. Otherwise, I will still get you that sample.
I think I figured it out.. this seems to work, works either in the grid itself or as a usercontrol resource
<UserControl.Resources> <Style TargetType="{x:Type igDP:DataRecordCellArea}"> <Setter Property="BackgroundActive" Value="{Binding DataContext.ActiveGridRowColor, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Mode=OneWay}"/> </Style></UserControl.Resources>
One thing I noticed though is that for each row in the grid, the property is read, is there any way to make the BackgroundActive read once and set it for the whole grid?
Yup, .net 4 and VS2010 with infragistics 2k10 vol2
It may be a DataContext conflict. Try making the data more accessible to both the Style and to the XamDataGrid. Right now you are binding the Style to the DataContext of the XamDataGrid.
I will post a sample that illustrates how to make this work based on what I know of your data. Are you using WPF 4.0 and Visual Studio 2010?
Thanks,
Yep pretty much... I'm also using Prism, I didn't mention that before because I didn't think it was related, but who knows... Unfortunately I can't send you the code to my project due to my company's policies.. Oh well, it's not a show stopping issue, I might just not allow users to change the color :) Thank you so much for your help, Curtis. I certainly appreciate it. If I somehow figure out the issue, I'll let you know.