标签:property too oca ali obj res lte resource led
原文:WPF GridControl单元格值与过滤值相同时,改变单元格背景色
DataTrigger的Value不可绑定,所以我们需要用MultiBinding来实现这个功能。
<dxg:TableView.CellStyle> <Style TargetType="{x:Type dxg:LightweightCellEditor}" BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=LightweightCellStyle}}"> <Style.Triggers> <DataTrigger Value="True"> <DataTrigger.Binding> <MultiBinding Converter="{StaticResource multiValueEqualityConverter}"> <Binding Path="Value" Mode="OneWay" /> <Binding RelativeSource="{RelativeSource AncestorType={x:Type local:WI}}" Path="DataContext.CurrentFilterValue" Mode="OneWay" /> <Binding RelativeSource="{RelativeSource AncestorType={x:Type local:WI}}" Path="DataContext.FIsFilter" Mode="OneWay" /> </MultiBinding> </DataTrigger.Binding> <Setter Property="Background" Value="Orange"/> </DataTrigger> </Style.Triggers> </Style> </dxg:TableView.CellStyle>
public class MuliteConvertEqual : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values != null) { if (values[0] != null && values[1] != null && values[2] !=null) { if (values[0].ToString() == values[1].ToString()&& System.Convert.ToBoolean(values[2])==true) { return true; } } } return false; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { return null; } }
将单元格的值,viewmodel中的过滤值进行MultiBinding,在converter中进行比较,如果相同,则触发单元格背景色变色。
WPF GridControl单元格值与过滤值相同时,改变单元格背景色
标签:property too oca ali obj res lte resource led
原文地址:https://www.cnblogs.com/lonelyxmas/p/12155459.html