我想在AutoCompleteBox中的多个字段中搜索,如果用户开始输入字符,我想在 ClientName 中搜索,如果用户开始输入数字,我要在 ClientNumber 中搜索
我在互联网上进行搜索,并从Answer上了解到,我应该使用 Converter 完成我想要的操作,但不幸的是,他们没有解释如何编写转换器!
这是AutoCompleteBox
<toolkit:AutoCompleteBox x:Name="txbClientName" FilterMode="StartsWith" IsTextCompletionEnabled="True"
ItemsSource="{Binding ocClients}"
ValueMemberBinding="{Binding Converter= {StaticResource ClientSearch}}"
SelectedItem="{Binding ElementName=this,
Path=ContactPerson,
Mode=TwoWay,
UpdateSourceTrigger=LostFocus}" PreviewKeyUp="txbClientName_PreviewKeyUp" LostFocus="txbClientName_LostFocus">
<toolkit:AutoCompleteBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="{Binding ContactPerson}"/>
</StackPanel>
</DataTemplate>
</toolkit:AutoCompleteBox.ItemTemplate>
ClientSearch 转换器应该做什么?
public class ClientSearchConverter : IValueConverter
{
public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
//What should I write here !!!
}
public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new System.NotImplementedException();
}
}
请帮忙!