使用ItemTemplate进行串联时,WPF跳转到类型化字符



当使用DisplayMemberPath时,它按预期工作-它跳到类型化的字符,但在以下情况下,我需要连接两个字段,姓氏和名称,并希望跳到姓氏,但它不工作。有人知道解决方案吗?以下是示例:

<ComboBox ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.AllDoctors}" SelectedValue="{Binding Path=Doctor.Id}" SelectedValuePath="Id" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} {1}">
<Binding Path="Surname"/>
<Binding Path="Name"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>                                
</ComboBox>

TextSearch.TextPath附加的属性添加到ComboBox,然后将CCD_ 3设置为CCD_。

<ComboBox IsTextSearchEnabled="True" TextSearch.TextPath="Surname" ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.AllDoctors}" SelectedValue="{Binding Path=Doctor.Id}" SelectedValuePath="Id" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} {1}">
<Binding Path="Surname"/>
<Binding Path="Name"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>

最新更新