I am using a DataTrigger to set the background property of the CellValuePresenter. The converter sets the background color based on value in Field1Dummy as shown below...
<DataTrigger Binding="{Binding Path=Field.Name, RelativeSource={RelativeSource Self}}" Value="Field1"> <Setter Property="Background" Value="{Binding Path=Cells[Field1Dummy].Value, Converter={StaticResource myconv}}"/> </DataTrigger>
The above logic works fine. I have also set property SelectionTypeCell to Range. However, when I select a range a cells, the cell borders change color but background remains white. In other xamDataGrids that I have used, all the cells that are selected turn skyblue in color. I guess, the above DataTrigger the above DataTrigger might be conflicting with the background of selected cells.
I have tried:
<Setter Property="BackgroundSelected" Value="DarkBlue"/>
but the above doesn't seem to have any impact. Basically, I just want the selected range of cells to have color DarkBlue (or even the default is fine). How do I do this?
Thanks.
Hello Jay,
Thank you for your reply. I've attached a sample that demonstrates multiple columns with the same selected background color. Based on your code snippet I don't know what the trigger is for. Keep in mind that both the cellvaluepresenter and datarecordcellarea have hover and active backgrounds that you can either set to the same color or transparent to hide the default "skyblue" color you see.
Please see my attached sample as I've demonstrated that you can selected and cell, across any column and it will only show one color.
Let me know if you have any questions.
Can someone please help with this!
I have attached a snippet - I am selecting a range of cells across two columns - the first column has a background set and the second does not. As you can see, in the first column only the cell border is highlighted but in the second column all selected cells are highlighted.
Thank you for contacting Infragistics. First I would make sure that CellClickAction is sett to SelectCell. This will enforce that cells can be selected instead of records (by default). Then you can style records and cells based on your requirement.
eg.
<Window.Resources> <Style TargetType="{x:Type igDP:DataRecordCellArea}">
<Setter Property="BackgroundSelected" Value="Red"/>
<Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path= Record.Cells[0].Value}" Value="John Smith"> <Setter Property="Background" Value="Orange" /> </DataTrigger> </Style.Triggers>
</Style>
<Style TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="BackgroundSelected" Value="DarkBlue"/> </Style>
</Window.Resources> <Grid> <igDP:XamDataGrid BindToSampleData="True" Margin="50" Name="xamDataPresenter1" > <igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings CellClickAction="SelectCell"/> </igDP:XamDataGrid.FieldSettings> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoGenerateFields="True" SelectionTypeCell="Range"></igDP:FieldLayoutSettings> </igDP:XamDataGrid.FieldLayoutSettings> </igDP:XamDataGrid> </Grid></Window>
Let me know if you havea any questions.