WPF中的多绑定实现
wpf 有时候有多绑定的需求
需要多绑定MultiBinding 节点报告,如
<Style x:Key="Color_Patient" TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Foreground"> <Setter.Value> <MultiBinding Converter="{StaticResource ColorEConvert}" Mode="TwoWay"> <Binding Path="DataItem.ADM_ID_ISS"></Binding> <Binding Path="DataItem.ISEXIGENCE"></Binding> <Binding Path="DataItem.REQ_SERVICE"></Binding> </MultiBinding> </Setter.Value> </Setter> <Setter Property="Background" Value="{Binding Path=DataItem.REMARK,Converter={StaticResource ColorFConvert}, Mode=TwoWay}"/> </Style>
后台转换: 需要界面多绑定接口 IMultiValueConverter,第一个参数就是绑定的输入值
//定义值转换器 [ValueConversion(typeof(string), typeof(string))] public class ColorEConvert : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { return null; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { return null; } }