包含表面交互元素的 ScatterViewItems

发布于 2024-07-24 16:21:00 字数 419 浏览 7 评论 0原文

这是交互元素内部交互元素的一个古老问题,但我希望 ScatterViewItem 包含其他表面交互元素,例如 SurfaceButton 或 SurfaceCheckBox。 我的所有元素都在那里,它们会对点击等做出反应。问题是,只有在单击不包含控件的区域时,我才会获得正常的 ScatterView 行为。

是否有一个优雅的解决方案,即使当联系人位于 SurfaceButton 或 SurfaceCheckbox 上时也允许拖动?

例如

<s:ScatterView >    
    <Grid Width="200" Height="200">
        <s:SurfaceButton />
    </Grid>
</s:ScatterView>

This is an age old problem of interactive elements inside interactive elements, but I want a ScatterViewItem to contain other surface interactive elements such as a SurfaceButton or SurfaceCheckBox. I've got all my elements in there and they react to taps etc. The problem is that I only get the normal ScatterView behavior once I click on an area that does not contain a control.

Is there an elegant solution to allow dragging even when the contact is on a SurfaceButton or SurfaceCheckbox?

e.g.

<s:ScatterView >    
    <Grid Width="200" Height="200">
        <s:SurfaceButton />
    </Grid>
</s:ScatterView>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夜清冷一曲。 2024-07-31 16:21:00

在 Surface 社区论坛上询问相同的问题后,得到的答复是这与所有 WPF 控件行为一致。 例如,如果将交互元素添加到列表框,则当鼠标悬停在按钮上时,列表框不会对交互做出反应。

如果其他人遇到此问题,最好通过控件的设计来解决此问题,而不是尝试将此行为整合在一起。 一个应用程序与另一个应用程序以及一个控件与另一个控件之间的控制行为应保持一致。

After asking the same question on the surface community forums, the response was that this is consistent with all WPF control behavior. For instance if you add interactive elements to a list box, the ListBox will not react to interactions when the mouse is over the button.

If anyone else comes across this problem, it is probably best to solve this problem through the design of the control rather than trying to hack this behavior together. Control behavior should remain consistent from one app to another and one control to another.

匿名。 2024-07-31 16:21:00

您可以通过侦听子控件之一上的 ContactLeave 事件来“破解”此行为,然后调用 contact.Capture( scatterviewitem)。 这将告诉 SVI 接管监听和响应联系。 但是,它将导致与 Surface 其他部分不一致的行为,并且可能会令人困惑。 它甚至与自身不一致...这使得无需抬起手指即可从内部控制切换到 SVI,但用户仍然必须抬起手指才能切换回内部控制。

you can 'hack' this behavior in by listening to ContactLeave events on one of the child controls and in that, call contact.Capture( scatterviewitem). this will tell the svi to take over listening to and responding to the contact. however, it is going to result in behavior inconsistent with other parts of Surface and may be confusing. it's also inconsistent even with itself... this makes it possible to switch from inner control to SVI without lifting your finger but the user still has to lift their finger to switch back to the inner control.

晨光如昨 2024-07-31 16:21:00

要解决此问题,区分预览和非预览事件非常重要:

http://eightyeightpercentnerd.blogspot.com/2008/06/wpf-preview-vs-non-preview-events.html

这样您就可以决定要收听哪个事件。

然而,作为一般建议,如果不应进一步路由事件,则将事件的已处理标志设置为 true 始终是一个好主意。

To solve this problem, it is important to distinguish between preview und non-preview events:

http://eightyeightpercentnerd.blogspot.com/2008/06/wpf-preview-vs-non-preview-events.html

So you can decide which event you want to listen to.

However as a general advice, it is always a good idea to set the Handled Flag of an event to true, if it shouldn't be routed any further.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文