CaptureMouse,MouseRightButtonDown,它适用于Silverlight 4吗? [英] CaptureMouse, MouseRightButtonDown, Does it work for Silverlight 4?

查看:89
本文介绍了CaptureMouse,MouseRightButtonDown,它适用于Silverlight 4吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
在我的Silverlight 4应用程序中,CaptureMouse()调用似乎不适用于MouseRightButtonDown事件.下面的代码显示以下内容:
(1)按住IE Web浏览器窗口内的鼠标左键并保持向下,直到鼠标移至Web浏览器窗口外,如果此时松开鼠标左键,将到达功能UserControl_MouseLeftButtonUp .
(2)按住IE Web浏览器窗口内的鼠标右键,并保持按下状态,直到将鼠标移到Web浏览器窗口外,如果此时释放鼠标右键,则将不会使用UserControl_MouseRightButtonUp函数.达到了.

为什么无法访问UserControl_MouseRightButtonUp?

Hello,
The CaptureMouse() call doesn''t appear to be working for the MouseRightButtonDown event in my Silverlight 4 application. The code below shows the following:
(1) When holding down the left mouse button inside the IE web browser window, and keeping the button down until the mouse is moved outside the web browser window, if you release the left mouse button at this point, the function UserControl_MouseLeftButtonUp will be reached.
(2) When holding down the right mouse button inside the IE web browser window, and keeping the button down until the mouse is moved outside the web browser window, if you release the right mouse button at this point, the function UserControl_MouseRightButtonUp will not be reached.

Why won''t UserControl_MouseRightButtonUp be reached?

<UserControl x:Class="sidebar.MainPage"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"

    mc:Ignorable="d"

    d:DesignHeight="300" d:DesignWidth="400" 

             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" xmlns:my="clr-namespace:sidebar"

             MouseLeftButtonDown="UserControl_MouseLeftButtonDown"

             MouseLeftButtonUp="UserControl_MouseLeftButtonUp"

             MouseRightButtonDown="UserControl_MouseRightButtonDown"

             MouseRightButtonUp="UserControl_MouseRightButtonUp"

             >

    <Grid x:Name="LayoutRoot" removed="White">
    </Grid>
</UserControl>


-------------------------------------------------- ------------------------------------


--------------------------------------------------------------------------------------

using System.Windows.Controls;
using System.Windows.Input;

namespace sidebar
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            CaptureMouse();
        }

        private void UserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("LeftMouseUp");
        }

        private void UserControl_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            CaptureMouse();
            e.Handled = true;
        }

        private void UserControl_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("RightMouseUp");
        }
    }
}

推荐答案

这本书来自Google图书( ^ ])似乎暗示可以通过鼠标左键而不是鼠标右键来捕获鼠标.如果有人能证明我错了,请这样做!
This book from Google books (http://books.google.com/books?id=PJmgeIdZT3YC&pg=PA117&lpg=PA117&dq=silverlight+mouse+%22capture%22+right+button&source=bl&ots=VtN1mnkpsa&sig=yHvxHw03Wbg7XDpjusGclYDKgJw&hl=en&sa=X&ei=z_FgT7rPKcO2gwf5guiWCA&ved=0CFsQ6AEwCQ#v=onepage&q=capture&f=false[^]), page 127, seems to suggest that mouse capture can be done by the left mouse button and not the right mouse button. If anyone can prove me wrong, please do!


这篇关于CaptureMouse,MouseRightButtonDown,它适用于Silverlight 4吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆