Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drawer控件对话框无法设置弹出后默认的焦点控件 #479

Closed
KevinL2015 opened this issue Nov 12, 2024 · 6 comments · Fixed by #481
Closed

Drawer控件对话框无法设置弹出后默认的焦点控件 #479

KevinL2015 opened this issue Nov 12, 2024 · 6 comments · Fixed by #481

Comments

@KevinL2015
Copy link

我在 overlay modal Drawer对话框控件里用如下代码设置了焦点,发现无效,有没有合适的方法在Drawer对话框出来后使得焦点到某个控件上?

UserNameTextBox.AttachedToVisualTree += (_, _) => UserNameTextBox.Focus();

看起来是 #316 与这个有关。

@rabbitism
Copy link
Member

可以尝试下在loaded之后再focus?

@KevinL2015
Copy link
Author

大佬好快的速度。

也不行,dawer出来时有个动画,loaded里设置也无效,看起来是我的代码设置之后,又再次被设置了,但是不知道设置到哪里去了。

@rabbitism
Copy link
Member

大佬好快的速度。

也不行,dawer出来时有个动画,loaded里设置也无效,看起来是我的代码设置之后,又再次被设置了,但是不知道设置到哪里去了。

那下个版本尽量出一个fix

@KevinL2015
Copy link
Author

辛苦了!

测试demo里Drawer,看上去焦点尝试给DefaultDrawerControl的Border去了(Name="PART_Root")
image
image

@KevinL2015
Copy link
Author

我在代码里加了样式,把PART_Root的Focusable改成false了,焦点就正常了,但我不确定有没有其他副作用。

<Style Selector="u|CustomDrawerControl /template/ Border#PART_Root.Shadow">
    <Setter Property="Focusable" Value="False" />
</Style>

@rabbitism
Copy link
Member

我在代码里加了样式,把PART_Root的Focusable改成false了,焦点就正常了,但我不确定有没有其他副作用。

<Style Selector="u|CustomDrawerControl /template/ Border#PART_Root.Shadow">
    <Setter Property="Focusable" Value="False" />
</Style>

主要作用是让模态对话框真的处于模态状态,保证焦点不会泄漏到主窗口的内容,对于你这个case因为你确保有其他的焦点,所以不会有什么问题,但是不能保证其他Dialog都有焦点。

@rabbitism rabbitism linked a pull request Nov 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants