none
一个BUTTON控件的IsMouseOver的问题 RRS feed

  • 问题

  • 一个用户控件代码

    public OneCodeButton()
            {
                this.MouseEnter += (sender, e) =>
                {
                    this.Background = MoveBackground;
                };
                this.MouseLeave+= (sender, e) =>
                {
                  
                    this.Background = LeaveBackground;
                };

            }

    当用户BUTTON控件的IsMouseOver为fals时候就把背景设置为NULL。没有这个事件获取。.MouseLeave不能一直处理。有没有,一直监控BUTTON的手势移动事件

    2014年12月22日 9:41

答案

  • 你好,

    >>没有这个事件获取。.MouseLeave不能一直处理

    请问OneCodeButton函数你是如何调用的,如果我们在后台处理MouseEnter 和 MouseLeave事件,是可以一直处理的:

    <Button Name="btn" Height="100" Content="Button" MouseEnter="btn_MouseEnter" MouseLeave="btn_MouseLeave" />

    private void btn_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
    {
                
                btn.Background = mySolidColorBrush;
    }
    
    private void btn_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
    {
                btn.Background = null;
    }


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年12月23日 5:31
    版主