我有一个带有控件的列表框,控件中填充了文本框和组合框。当我编辑文本框并在组合中选择时,我需要选择基础列表项。似乎无法找到解决方案。任何人吗?
<ListBox.ItemTemplate>
<DataTemplate>
<Controls:ComponentEditItem Background="Transparent"/>
</DataTemplate>
</ListBox.ItemTemplate>
答案 0 :(得分:0)
您可以添加EventTrigger
,以便在其中一个控件聚焦时选择基础ListBoxItem
。像这样:
<ListBox.ItemTemplate>
<DataTemplate>
<Controls:ComponentEditItem Background="Transparent">
<Controls:ComponentEditItem.Triggers>
<EventTrigger RoutedEvent="GotFocus">
<BeginStoryboard>
<Storyboard>
<BooleanAnimationUsingKeyFrames Duration="00:00:00" Storyboard.Target="{Binding Path=., RelativeSource={RelativeSource FindAncestor, AncestorType=ListBoxItem}}" Storyboard.TargetProperty="IsSelected">
<DiscreteBooleanKeyFrame Value="True" />
</BooleanAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Controls:ComponentEditItem.Triggers>
</Controls:ComponentEditItem>
</DataTemplate>
</ListBox.ItemTemplate>