WPF:画布 Z 索引错误
所以我在WPF中制作了自己的轮播控件。 我偶然发现了一个错误,想知道是否有人知道我如何解决这个问题,例如方法调用或一系列方法调用或一些解决方法。 这是我的轮播的打印屏幕:
轮播图像 http://img4.imageshack.us /img4/9599/carousele.jpg
正如您在这张图片中可以清楚地看到的,我的鼠标指针位于写有 16 的按钮上方。 但是上面写着 18 的按钮是蓝色的,就好像我的鼠标悬停在该按钮上一样。 我还将工具提示设置为绑定到内容,工具提示显示我的鼠标位于 18 号按钮上方。 这应该是正确的行为,因为 18 是按钮的 z-index 值。 因此,带有 18 的按钮应该位于带有 16 的按钮的顶部。 然而,WPF 并没有以这种方式渲染画布,我想知道如何克服这个问题。 我尝试了 canvas.InvalidateArranage()、canvas.invalidateVisual()、canvas.UpdateLayout() 但没有运气。 画布的左侧显示了它应有的样子,但即使 z-index 值正确,右侧也无法产生相同的结果,甚至这个屏幕截图也证明了我的观点,即这是 WPF 中的一个错误。
So I made my own carousel control in WPF. I have stumbled upon a bug and was wondering if anyone knew how I could fix this like a method call or a series of methods calls or some work-around. Here is a print screen of my carousel:
Carousel Image http://img4.imageshack.us/img4/9599/carousele.jpg
As you can CLEARLY see with this image, my mouse pointer is OVER the button with 16 written on it. But the button with 18 written on it is the one that is blue as if my mouse were over that button. I also set the tooltip to be bound to the content and the tooltip says my mouse is over the button with 18 one it. This should be the CORRECT behavior as 18 is the buttons z-index value. Thus the button with 18 on it should be ON TOP of the button with 16 on it. However, WPF did not render the canvas in such a fashion and I was wondering how to overcome this. I tried canvas.InvalidateArranage(), canvas.invalidateVisual(), canvas.UpdateLayout() but I had no luck. The left side of the canvas shows what it should look like, but the right side fails to produce the same result even though the z-index values are correct, and even this screenshot proves my point that this is a bug in WPF.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 wpf 中,从技术上讲,您的鼠标超过 18。事件(可能)被触发的方式如下:
我超过“16”,调用鼠标悬停为 16
我已经超过“18”,将鼠标悬停调用为 18
由于 18 是最近调用的,因此它被选中(再次,只是我的猜测)。
在 mousemove 事件的事件参数中(我假设 mousemove),确保设置 e.Handled = true,这样它只处理一次
In wpf, technically your mouse IS over 18. The way the events (may) be triggered is as follows:
I'm over "16", call the mouseover for 16
I'm over "18", call the mouseover for 18
Since 18 was the most recently called, it's selected (again, just my guess).
In the event args for the mousemove event (I assume mousemove), make sure to set e.Handled = true, this way it's only processed once