禁用的 UserControl 内的 Silverlight 4 和 MouseLeave 事件
我的启用 RIA 的 SL 应用程序有一个小问题。
背景:
相关部分如下所示:
当任何数据操作(即加载, 提交、登录等)已就位,然后 BusyOverlay 控件(我写的) 禁用 RootVisual 并提供 视觉效果。当 操作完成,然后设置 RootVisual.IsEnabled 到任何它 是之前。它的工作原理就像 ChildWindow 当涉及到 与 RootVisual 交互(至少 据我所知)。
RootVisual(其本身是一个 UserControl)中的元素之一是隐藏菜单。它是包含实际菜单的边框。它在资源中有两个故事板(它们增加和减少它的宽度 - 没什么花哨的,它们就像你想象的那么简单),并且边框本身有 MouseEnter 和 MouseLeave 处理。处理程序启动一个故事板,只需一行代码。我不提供任何示例,因为没有什么有趣的事情发生,它只会使帖子变得臃肿。如果您认为有必要,请告诉我,我将发布相关的 XAML 和 C# 代码。
问题:
当 RootVisual 被禁用时,Border.MouseLeave 事件不会触发。当用户单击加载初始数据的菜单中的某些内容,然后将鼠标移到菜单之外时,它不会隐藏。有没有办法优雅的解决这个问题呢? CaptureMouse 是没有问题的(它需要按下鼠标左键)。我能想到的就是在我的数据操作处理静态类中发布一个“OperationFinished”事件,并在 UserControl(RootVisual)中处理它,但我认为它很丑陋,不适合我的体系结构。我有什么遗漏的吗?
我将不胜感激任何解决方案和建议。
I have a little problem with my RIA-enabled SL application.
THE BACKGROUND:
The relevant part looks like this:
When any data operation (i.e. load,
submit, login etc.) is in place, then
a BusyOverlay control (which I wrote)
disables RootVisual and provides a
visual effect. When the
operation is finished, then it sets
RootVisual.IsEnabled to whatever it
was before. It works just like
ChildWindow when it comes to
interaction with RootVisual (at least
as far as I can tell).One of the elements in RootVisual (which itself is a UserControl) is a hiding menu. It is a border which contains the actual menu. It has two storyboards in Resources (which increase and decrease it's width - nothing fancy, they are as simple as you can imagine), and the border itself has MouseEnter and MouseLeave handled. The handlers start one of the storyboards, just one line of code. I don't provide any samples because there is nothing interesting going on, it would just bloat the post. If you think it is necessary, just tell me and I'll post the relevant XAML and C# code.
THE PROBLEM:
When the RootVisual is disabled, then the Border.MouseLeave event does not fire. When user clicks something in the menu that loads initial data, and then moves the mouse outside the menu, it does not hide. Is there any way to elegantly solve this problem? CaptureMouse is out of question (it requires mouse left button to be down). All I can think of is to publish an "OperationFinished" event in my data operation handling static class and handle it in the UserControl which is RootVisual, but I think it's ugly and doesn't fit in my architecture. Is there something I'm missing?
I'll be grateful for any solutions and suggestions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论