【发布时间】: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