WPF AutoCompleteBox多个ValueMemberPath

时间:2013-01-08 18:59:00

标签: wpf c#-4.0 ivalueconverter autocompletebox

我有一个CollectionViewSource,其中填充了来自数据库的业务对象。设置 AutoCompleteBox ValueMemberPath =“LNAME”按预期用于所有姓氏。但是,我想同时搜索名字和订单号,而不必使用单选按钮或下拉列表来定义搜索类型。

我已将ValueMemberPath更改为ValueMemberBinding:

ItemsSource="{Binding Source={StaticResource TheCollectionViewSource}}"
ValueMemberBinding="{Binding Converter={StaticResource ValueMemberPathConverter}}"

我不确定如何在转换器中组合LNAME,FNAME等

public class Converter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return foo;
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return foo;
        }
}

1 个答案:

答案 0 :(得分:1)

public Binding ValueMemberBinding
    {
      get
      {
        return _valueBindingEvaluator != null ?
          _valueBindingEvaluator.ValueBinding : null;
      }
      set
      {
        if (_valueBindingEvaluator == null)
        {
          _valueBindingEvaluator = new BindingEvaluator<string>();
          AddLogicalChild(_valueBindingEvaluator);
        }
        _valueBindingEvaluator.ValueBinding = value;
      }
    }