【发布时间】:2021-03-04 01:05:49
【问题描述】:
我有一个 UWP XAML ListView,我想在使用箭头键在项目之间切换时处理焦点事件。但是,我不知道如何处理我的项目的焦点事件:
<ListView ItemsSource="{x:Bind Items}"
CanDragItems="True" CanReorderItems="True" AllowDrop="True"
SelectionMode="None" IsItemClickEnabled="True" ItemClick="ListView_ItemClick">
<ListView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<!-- Never fires, even with Control.IsTemplateFocusTarget="True" : -->
<StackPanel GotFocus="StackPanel_GotFocus">
<!-- Never fires: -->
<TextBlock Text="{x:Bind}" GotFocus="TextBlock_GotFocus" />
<Button Content="Foo" IsTabStop="False" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<!-- Never fires: -->
<ListViewItemPresenter [...]
GotFocus="Root_GotFocus" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
</ListView>
我还能在哪里收听这些焦点事件?
谢谢!
【问题讨论】:
标签: xaml uwp windows-runtime