快捷搜索:  as  2018  FtCWSyGV  С˵  test  xxx  Ψһ  w3viyKQx

缅甸云鼎和记娱乐官网_机器人论坛



一:创建Silverlight2 类库项目

启动VS2008,选择新建项目,创建Silverlight2 类库项目,然后我们添加一个控件类,输入新的项目名:MyButton。此类可以承袭自Control类,也可以承袭自其他类比如 ContentControl,ItemControl。我们承袭自Button,代码如下:

using System;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Ink;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Animation;

using System.Windows.Shapes;

namespace MyButton

{

public class MyButton :Button

{

}

}

二、对此类添加事故处置惩罚

protected ov缅甸云鼎和记娱乐官网erride void OnMouseLeftButtonDown(MouseButtonEventArgs e)

{

base.OnMouseLeftButtonDown(e);

e.Handled = false;

}

protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)

{

base.OnM缅甸云鼎和记娱乐官网ouseLeftButtonUp(e);

e.Handled = false;

}

完备代码如下:

using System;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Ink;

using System.Windows.Input;

using System.Windows.Media;

using System.Windo缅甸云鼎和记娱乐官网ws.Media.Animation;

using System.Windows.Shapes;

namespace MyButton

{

public class MyButton :Button

{

protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)

{

base.OnMouseLeftButtonDown(e);

e.Handled = false;

}

protected override void OnMouseLe缅甸云鼎和记娱乐官网ftButtonUp(MouseButtonEventArgs e)

{

base.OnMouseLeftButtonUp(e);

e.Handled = f缅甸云鼎和记娱乐官网alse;

}

}

}

三、编译并天生项目即可,若何引入和利用此自定义按钮,拜见:" SilverLigth进修条记--若何办理Button不相应MouseLeftButtonDown与MouseLeftButtonUp事故的问题" 一文

您可能还会对下面的文章感兴趣: