我有一个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;
}
}
答案 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;
}
}