Wpf Devexpress DXGrid-打印/导出自定义单元格样式

Wpf Devexpress DXGrid-打印/导出自定义单元格样式,wpf,excel,printing,devexpress,Wpf,Excel,Printing,Devexpress,我是DE控制方面的新手,我仍在评估产品,我有一个小问题 我有一个网格,它有两列,其背景色由记录状态定义(例如,如果状态为1,单元格的背景色必须为红色)。对于collumn的CellStyle,我使用我的定制CellStyle,一切都很好 <Style x:Key="customCellStyle" BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=CellStyle}}" TargetType="{x:Type dxg:C

我是DE控制方面的新手,我仍在评估产品,我有一个小问题

我有一个网格,它有两列,其背景色由记录状态定义(例如,如果状态为1,单元格的背景色必须为红色)。对于collumn的CellStyle,我使用我的定制CellStyle,一切都很好

<Style x:Key="customCellStyle" BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=CellStyle}}" TargetType="{x:Type dxg:CellContentPresenter}">
    <Setter Property="Background">
        <Setter.Value>
            <MultiBinding>
                <MultiBinding.Converter>
                    <local:StatusToBackroundColorConverter />
                </MultiBinding.Converter>
                <Binding Path="Column" RelativeSource="{RelativeSource Self}" />
                <Binding Path="Data.RowHandle.Value" />
                <Binding Path="Data.DocumentStatusId" />
            </MultiBinding>
        </Setter.Value>
    </Setter>

但是,当我尝试导出或打印网格视图时,它根本不起作用。虽然,如果单元格的背景颜色是硬代码,它就可以工作,但我无法使它与绑定一起工作。代码如下所示:

为了简单起见,这里我不使用转换器;StatusBackColor有一种画笔类型

<Style x:Key="customPrintCellStyle" BasedOn="{StaticResource {dxgt:TableViewThemeKey ResourceKey=DefaultPrintCellStyle}}" TargetType="dxe:TextEdit">
    <Style.Setters>
        <Setter Property="dxp:ExportSettings.TargetType" Value="Panel"/>        
        <Setter Property="DisplayTemplate">
            <Setter.Value>
                <ControlTemplate TargetType="dxe:TextEdit">
                    <dxe:TextEdit Text="{Binding Value}"
                                          TextWrapping="Wrap"
                                          IsPrintingMode="True"
                                          Margin="4"
                                          VerticalContentAlignment="Center"
                                          HorizontalContentAlignment="Left"  
                                          dxp:ExportSettings.Background ="{Binding Path=StatusBackColor}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style.Setters>
</Style>

使用静态(dxp:ExportSettings.Background=“red”)颜色,它可以工作

有什么想法吗?请帮忙,我被卡住了:)


KR,Sebastjan

我知道这很旧,但如果有人像我一样来到这里,您可能需要修改绑定表达式以访问行的数据。对于PrintCellStyle,可以通过RowData.Data执行此操作,因此表达式变为

dxp:ExportSettings.Background ="{Binding Path=RowData.Row.StatusBackColor}"

要在dxp:ExportSettings.Background上绑定,需要颜色属性,而不是笔刷属性

您使用的是哪个版本的dev express?