【问题标题】:Devexpress DXGrid - printing/exporting a custom cell styleDevexpress DXGrid - 打印/导出自定义单元格样式
【发布时间】:2011-07-29 07:40:13
【问题描述】:

我是 DE 控件的新手,我仍在评估产品,但遇到了一个小问题。

我有一个网格,它有两列,其背景色由记录状态定义(例如,如果状态为 1,则单元格的背景色必须为红色)。对于 collumn 的 CellStyle,我正在使用我的自定义 customCellStyle 并且一切正常。

<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>

但是,当我尝试完成导出或打印网格视图时,它根本不起作用。虽然,如果单元格的背面颜色是硬编码,它可以工作,但我不能让它与 binding 一起工作。代码如下:

为了简单起见,我没有使用转换器; StatusBackColor 有一种 Brush。

<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>

使用 static(dxp:ExportSettings.Background ="red") 颜色即可。

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

韩国,塞巴斯蒂安

【问题讨论】:

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

标签: wpf excel printing devexpress


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    您需要一个颜色属性,而不是画笔属性,才能在 dxp:ExportSettings.Background 上绑定。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 2019-06-22
      • 1970-01-01
      • 2013-05-01
      • 1970-01-01
      • 2015-02-09
      相关资源
      最近更新 更多