Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1865
Background of Selected Range
posted

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.

Parents
No Data
Reply
  • 28945
    Suggested Answer
    Offline posted

    Hello Jay,

    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.

Children