带有 IsDefault 和 IsDefaulted 的按钮有什么区别? [英] What's the difference between a button with IsDefault and IsDefaulted?

查看:27
本文介绍了带有 IsDefault 和 IsDefaulted 的按钮有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能更好地解释我?

我只是阅读文档并不太明白.

I didn't understand too much just reading the documentation.

推荐答案

如果将 IsDefault 设置为 true,则按钮将成为窗口的默认按钮,即当前焦点时按下 ENTER 键不在任何接受 ENTER 键的可聚焦控件上,按钮单击事件将被触发.如果由于此默认操作可以触发按钮单击事件,则 IsDefaulted 将为真,否则为假.这意味着如果默认按钮在这种情况下具有焦点 IsDefaulted 将为 false,因为默认情况下不会触发事件.

If you set IsDefault to true, button will become the default button for the window i.e. if ENTER key is pressed when the current focus is not on any focusable control that accepts ENTER Key the button click event will be triggerred. If button click event can be triggered due to this default action then IsDefaulted will be true else it will be false. That means if the Default button has focus in this case IsDefaulted will be false as event will not be triggered by default.

IsDefaulted 是只读属性,它仅说明在当前焦点状态下默认情况下是否可以单击按钮,即当 Button 没有焦点时,可以在按下 ENTER 键时触发按钮单击事件.IsDefault 我们可以设置为 true 如果我们希望该按钮应该具有此默认行为,即当按下 ENTER 键并且即使按钮不在焦点上时,也应该触发按钮单击.我们设置 IsDefault.IsDefault 设置为 true 后将保持为 true,但 IsDefaulted 将根据当前具有焦点的控件更改其值.

IsDefaulted is readonly property which only tells if the button can be clicked by default at present state of focus i.e. the button click event can be triggered on ENTER press when Button did not has the focus. IsDefault we can set to true if we want that button should have this default behaviour i.e. when ENTER key is pressed and even button was not in focus button click should be triggered. We set IsDefault. IsDefault once set to true will remain true but IsDefaulted will change its value depending on which control currently has focus.

这篇关于带有 IsDefault 和 IsDefaulted 的按钮有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆