Silverlight MouseLeave 显示不一致的行为
所以,我的问题是只有当我以一定的速度移动光标时才会触发 MouseLeave 事件。下面是一个带有边框的拇指。单击拇指并按住鼠标按钮。缓慢移出边界 = 无事件,快速移出边界 = 事件。
<Grid x:Name="LayoutRoot" Background="White">
<Border BorderBrush="Black" BorderThickness="3" Width="200" Height="100"
MouseLeave="Border_MouseLeave">
<Thumb />
</Border>
</Grid>
private void Border_MouseLeave(object sender, MouseEventArgs e)
{
MessageBox.Show("Border_MouseLeave");
}
这是 silverlight 中的错误还是我错过了什么? 谢谢 /麦克风
So, my problem is that the MouseLeave event only gets triggered if I move my cursor at a certain speed. Below is a Thumb with a Border. Click the thumb and keep the mouse button down. Move slowly outside the border = no event, Move fast outside the border = event.
<Grid x:Name="LayoutRoot" Background="White">
<Border BorderBrush="Black" BorderThickness="3" Width="200" Height="100"
MouseLeave="Border_MouseLeave">
<Thumb />
</Border>
</Grid>
private void Border_MouseLeave(object sender, MouseEventArgs e)
{
MessageBox.Show("Border_MouseLeave");
}
Is it a bug in silverlight or am I missing something?
Thanx
/Mike
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢您的回答,这是更新:
正如 Guy 所建议的,这似乎与 MouseCapture 有关。原因是我在使用按钮或在代码隐藏中捕获鼠标的矩形时也遇到了问题。
如果我在拇指和边框之间放置一个网格,问题就会消失,所以我想我会这样做。
当我玩一些游戏时,我也注意到了一个相关的问题。
如果我按左键并将光标移动到矩形上方的左侧,则不会注册 MouseLeave 事件。
这一切都很奇怪。
Thanx for the anwers, here's an update:
It seems to have something to do with MouseCapture as Guy suggests. The reason being that I also get the problem using Button or a Rectangle that captures the mouse in code-behind.
If I put a Grid between the Thumb and the Border the problem disappears so I think I will go with that.
I also noticed a related problem as I played around some.
If I press the left button and move the cursor to the left over the Rectangle and out the MouseLeave event is not registered.
This is all very strange.