引用http://www.cnblogs.com/wsdj-ittech/archive/2009/07/15/1524112.html

在Silverlight 2和3 中的按钮不能响应MouseLeftButtonDown 和 MouseLeftButtonUp 事件,为解决此问题,我们可通过创建自定义按钮控件加以解决:

1. 在解决方案中添加Silverlight类库

2. 新建类MyButton,继承自Button,添加如下的事件处理:

protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)

    base.OnMouseLeftButtonDown(e);
    e.Handled = false;
}

protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)

    base.OnMouseLeftButtonUp(e); 
    e.Handled = false;
}

3. 在主模板中加入自定义按钮的引用:

xmlns:myButton="clr-namespace:MyButton;assembly=MyButton"

4. 然后这么添加Button:

<myButton:MyButton></myButton:MyButton>

这样Button就可以相应MouseLeftButtonDown 和 MouseLeftButtonUp 事件了。

ps:都3了还有这么弱智的bug,真不知道微软是怎么搞的,不知道4里面正不正常。

相关文章:

  • 2021-12-27
  • 2022-03-05
  • 2021-11-21
  • 1970-01-01
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
猜你喜欢
  • 2021-12-31
  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
  • 2022-12-23
  • 2022-01-25
相关资源
相似解决方案