在Microsoft Surface平台上使用WPF扩展器控件
我正在尝试在表面应用程序中使用 Expander 控件。我看到它不是表面控件,因此应用程序编译并显示控件,但触点不起作用。
无论如何,我可以修改接触事件并使其在表面应用程序中工作吗?
I am trying to use the Expander control in the surface application. I have seen its not a surface control so application compiles and control shows up but the contacts are not working.
Is there anyway I can modify the contact events and make it work in surface applications.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为此,您所要做的就是更改
Expander
的模板以使用 Surface 控件而不是常规控件。Expander
的默认模板可以在 http: //msdn.microsoft.com/en-us/library/ms753296.aspx。您需要更改的只是 ToggleButton:
更改为
(省略结束标记)
这假设
s
绑定到 Surface XML 命名空间:To do that, all you have to do is change the
Expander
's template to use Surface controls instead of the regular controls.The
Expander
's default template can be found at http://msdn.microsoft.com/en-us/library/ms753296.aspx.All you need to change is the ToggleButton:
changes to
(closing tags omitted)
This assumes
s
is bound to the Surface XML Namespace:我讨厌破坏这样一个古老的话题,但这是谷歌的最佳结果,我找到了一个更适合我的解决方案。
GUI 加载后,我使用 VisualTreeHelper 在运行时递归生成所有 GUI 对象的
List
。我的项目出于其他原因需要此 GUI 对象列表,但它也为我提供了一个非常简单的解决方案来为非 Surface 控件添加触摸支持。遍历 GUI 对象列表,找到 ToggleButtons(Expander 的实际可点击部分),打开其触摸支持,并在 TouchUp 触发时(当用户抬起手指时)将事件绑定到它们。
I hate to necro such an old topic but this was the top google result and I found a solution that worked better for me.
After my GUI loads I use the VisualTreeHelper recursively to generate a
List<DependencyObject>
of all the GUI objects at runtime. My project required this GUI object list for other reasons, but it also gave me a very simple solution to adding Touch-support for non-Surface controls.Iterate through the list of GUI objects, find the ToggleButtons (the actual clickable part of the Expander), turn on their touch-support, and bind an event to them when TouchUp is fired (when a user lifts their finger).