使用 Silverlight 4 将焦点设置到 XAML 中的 UIElement (即 TextBox )?
我只看到过这个问题的代码解决方案。我正在寻找基于 XAML 的解决方案,但我很惊讶您无法将焦点集中在 XAML 中的 UI 元素上。
我找到了这个旧的 MSDN 帖子: http: //social.msdn.microsoft.com/Forums/en/wpf/thread/09dc837d-4485-4966-b45b-266727bbb90c
具有我寻求的解决方案(我猜这只是 WPF )
<Grid FocusManager.FocusedElement="{Binding ElementName=listBox1}">
正在将焦点设置为Silverlight 4 XAML 中的 TextBox/ListBox 不可能吗?
I have only seen code solutions to this problem. I am looking for a XAML based solution and I am quiet surprised you can't set focus on a UI element in XAML.
I found this old MSDN post: http://social.msdn.microsoft.com/Forums/en/wpf/thread/09dc837d-4485-4966-b45b-266727bbb90c
that had the solution I sought ( this is WPF only I guess )
<Grid FocusManager.FocusedElement="{Binding ElementName=listBox1}">
Is setting focus to a TextBox/ListBox in Silverlight 4 XAML not possible ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您足够努力,XAML 中总有办法。 :) 您需要的是来自 Blend SDK 的
触发器
。然后使用它,例如:
如果您想要真正花哨,您可以 将条件应用于触发器并在 XAML 中执行各种疯狂的操作。我想说的是,我很惊讶这种东西没有内置。
There is always a way in XAML, if you try hard enough. :) What you need is a
Trigger
, from the Blend SDK.Then to use it something like:
If you want to get REALLY fancy, you can apply a condition to your trigger and do all sorts of crazy things in XAML. I will say I am surprised this sort of thing isn't built in though.
据我所知,不,XAML 中没有办法设置元素的焦点。您将不得不求助于您所引用的东西。我认为附加行为(类似于 FocusManager)将是最好的路线。
As far as I know, no, there is not a way in XAML to set the focus of an element. You'll have to resort to something like you've referenced. I think an attached behavior (similar to the
FocusManager
) would be the best route.