我是DE控件的新手,我还在评估产品,我有一个小问题。
我有一个网格,其中有两列,后面是由记录状态定义的(例如,如果状态为1,则单元格的背景颜色必须为红色)。对于collumn的CellStyle,我使用自定义的customCellStyle,并且Everything正常工作。
<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有一种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>
使用静态(dxp:ExportSettings.Background =“red”)颜色。
有什么想法吗?请帮忙,我被卡住了:)
KR,Sebastjan
答案 0 :(得分:2)
我知道这是旧的但是如果有人像我一样到达这里 - 您可能需要修改绑定表达式以访问行的数据。对于PrintCellStyle,您可以通过RowData.Data执行此操作,因此您的表达式变为
dxp:ExportSettings.Background ="{Binding Path=RowData.Row.StatusBackColor}"
答案 1 :(得分:0)
在dxp上需要一个Color属性而不是Brush属性:ExportSettings.Background。