WPF DevExpress中GridControl动态修改行背景颜色 - 借用的

<dxg:TableView.RowStyle>

    <Style TargetType="dxg:GridRowContent" BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=RowStyle}}">

        <Setter Property="Background" Value="{Binding Row.USER_ID, Converter={StaticResource conv}}"/>

    </Style>

</dxg:TableView.RowStyle>

  提示:“GridRowContent”TargetType 与元素“RowControl”的类型不匹配。

在dxg:TableView 中设置UseLightweightTemplates 为None 就可以了。

<dxg:GridControl.View>
                                <dxg:TableView    AllowPerPixelScrolling="True"  Name="tvSAP" AllowEditing="False" ShowTotalSummary="False" ShowGroupPanel="False"  UseLightweightTemplates="None">
                                    <dxg:TableView.RowStyle>
                                        <Style TargetType="dxg:GridRowContent" BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=RowStyle}}">
                                            <Setter Property="Background" Value="{Binding Row.ComponentCode, Converter={StaticResource NewSAPCodeConvert}}"/>
                                        </Style>
                                    </dxg:TableView.RowStyle>
                                </dxg:TableView>
                            </dxg:GridControl.View>

  

  1. <dxg:GridControl.View>
  2.  
    <dxg:TableView AllowPerPixelScrolling="True" Name="tvSAP" AllowEditing="False" ShowTotalSummary="False" ShowGroupPanel="False" UseLightweightTemplates="None">
  3.  
    <dxg:TableView.RowStyle>
  4.  
    <Style TargetType="dxg:GridRowContent" BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=RowStyle}}">
  5.  
    <Setter Property="Background" Value="{Binding Row.ComponentCode, Converter={StaticResource NewSAPCodeConvert}}"/>
  6.  
    </Style>
  7.  
    </dxg:TableView.RowStyle>
  8.  
    </dxg:TableView>
  9.  
    </dxg:GridControl.View
posted @ 2022-03-22 13:54  绝版佳嫐  阅读(786)  评论(0编辑  收藏  举报