xamdatagrid行背景颜色datatrigger

时间:2014-06-01 13:29:28

标签: wpf wpf-controls infragistics

我试图在Xamdatagrid中更改我的行的颜色 我有一个布尔值,我想绑定它。

我试图使用它 http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=10103

这是我的代码: 我的风格有问题:

igDP:XamDataGrid DataSource="{Binding ResultData}" DataContext="{Binding }" Grid.Row="6"
                          GroupByAreaLocation="None"
                          Width="Auto"
                          ActiveDataItem="{Binding SelectedItem}">
            <igDP:XamDataGrid.Resources>
                <Style TargetType="{x:Type igDP:DataRecordCellArea}">
                    <Setter Property="Background" Value="White">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem.CanBeCalculated}" Value="False">
                                <Setter Property="Background" Value="Red"></Setter>
                            </DataTrigger>
                        </Style.Triggers>
                    </Setter>
                </Style>
                </igDP:XamDataGrid.Resources>
                <igDP:XamDataGrid.InputBindings>
                    <MouseBinding MouseAction="LeftDoubleClick" Command="{Binding DisplayImageCommand}"/>
                </igDP:XamDataGrid.InputBindings>

错误MC3015:附加属性&#39; Style.Triggers&#39;没有定义在Setter&#39;或其中一个基类。

2 个答案:

答案 0 :(得分:4)

Style.Triggers 移出 Setter 元素。

<Style TargetType="{x:Type igDP:DataRecordCellArea}">
   <Setter Property="Background" Value="White"/> <-- HERE close the setter.
   <Style.Triggers>
     <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, 
                     Path=Record.DataItem.CanBeCalculated}" Value="False">
         <Setter Property="Background" Value="Red"></Setter>
     </DataTrigger>
   </Style.Triggers>
</Style>

答案 1 :(得分:1)

这就是将其放在文档中的答案 谢谢罗希特。

<igDP:XamDataGrid DataSource="{Binding ResultData}" DataContext="{Binding }" Grid.Row="6"
                          GroupByAreaLocation="None"
                          Width="Auto"
                          ActiveDataItem="{Binding SelectedItem}">
            <igDP:XamDataGrid.Resources>
                <Style TargetType="{x:Type igDP:DataRecordCellArea}" BasedOn="{StaticResource {x:Type igDP:DataRecordCellArea}}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem.CanBeCalculated}" Value="False">
                            <Setter Property="Background" Value="Tomato"></Setter>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </igDP:XamDataGrid.Resources>