Jportelas
Jportelas

Reputation: 646

Apply DataRecordPresenter style to a specific grid

I have a couple of xamDataGrids (version 11.2) on my WPF form. I created a style to colour the whole row yellow when a trigger is met.

<Style TargetType="{x:Type igDP:DataRecordPresenter}" >
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=somePropertyNameHere}" Value="1">
                <Setter Property="Background" Value="#ECEC85" />
            </DataTrigger>
        </Style.Triggers>
    </Style>

The thing is that the second grid viewModel doesn't have the property that the data trigger is using and this generates a binding exception that I would like to fix. So I think the easiest way to fix this is to apply the style to the first grid specifically but I don't know how to do this...any help please?

Upvotes: 0

Views: 1146

Answers (1)

Ayyappan Subramanian
Ayyappan Subramanian

Reputation: 5366

You can give a specific style to the grid. refer the below code.

<Page.Resources>
    <Style x:Key="FirstGridDRP" TargetType="igDP:DataRecordPresenter" >
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=somePropertyNameHere}" Value="1">
                <Setter Property="Background" Value="#ECEC85" />
            </DataTrigger>
        </Style.Triggers>
    </Style>
</Page.Resources>
<Grid>
    <igDP:XamDataGrid x:Name="FirstGird">
        <igDP:XamDataGrid.FieldLayoutSettings>
            <igDP:FieldLayoutSettings DataRecordPresenterStyle="{StaticResource FirstGridDRP}"/>
        </igDP:XamDataGrid.FieldLayoutSettings>
    </igDP:XamDataGrid>
    <igDP:XamDataGrid x:Name="SecondGrid">

    </igDP:XamDataGrid>
</Grid>

Upvotes: 1

Related Questions