将焦点设置为用户控制(c#UWP)

将焦点设置为用户控制(c#UWP),c#,xaml,uwp,focus,C#,Xaml,Uwp,Focus,我无法将焦点设置到UserControl。我希望控件在单击时获得焦点(指针按下事件) 下面是控件: <UserControl x:Class="MyApp.MyControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:MyApp" xmlns:d="ht

我无法将焦点设置到UserControl。我希望控件在单击时获得焦点(指针按下事件)

下面是控件:

<UserControl
x:Class="MyApp.MyControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="100"
d:DesignWidth="160"
Canvas.ZIndex="10"  
IsEnabled="True"
IsFocusEngagementEnabled="True"
AllowFocusOnInteraction="True"
UseSystemFocusVisuals="True">
...
</UserControl>

...
每当按下指针时,我在代码中调用这个.Focus(FocusState.pointer)。 但是,该方法始终返回false(无法设置FocusState,这仍然存在) 不集中注意力)。如何设置用户控件的焦点?

尝试添加IsTapEnabled=“True”IsTabStop=“True”


Quote:“通常只有交互的UI元素才能接收键盘焦点。例如,文本框是交互的,因为用户可以键入文本,而文本块不是交互的,因为文本是只读的。”。用户控件不是交互式的,当按下键盘上的键时,它不会做任何有意义的事情。它也不能显示焦点矩形。这就引出了一个问题:为什么需要它来获得焦点。不是100%确定
UserControl
可以设置为焦点。您的
用户控件中有什么?用户控件是由路径/省略号组成的逻辑门。我只是想在控件周围有一个边框,在控件聚焦时可以看到几个按钮,但我想如果这不是推荐/可能的方法,我会找到另一种方法,谢谢你的帮助。