我正在尝试UIElement
在用户控件中设置两个 s 的选项卡索引。用户控件包含一个文本框和按钮。我目前通过附加属性将焦点应用于文本框,但是我希望能够按 Tab 键并从文本块导航到按钮或检测按键(Enter 键)并触发按钮上的命令(我知道单独的问题)
主要重点是首先完成标签索引。
感谢您的任何指示或建议。
更新
从那以后,我尝试使用附加属性来处理跳转顺序
public static DependencyProperty TabIndexProperty = DependencyProperty.RegisterAttached("TabIndex", typeof(int), typeof(AttachedProperties), null);
public static void SetTabIndex(UIElement element, int value)
{
Control c = element as Control;
if (c != null)
{
RoutedEventHandler loadedEventHandler = null;
loadedEventHandler = new RoutedEventHandler(delegate
{
HtmlPage.Plugin.Focus();
c.Loaded -= loadedEventHandler;
c.Focus();
});
c.Loaded += loadedEventHandler;
}
}
但是,当我尝试编译时,我收到按钮控件的 TabIndex 属性不存在的错误。任何想法为什么这会失败?