I. Create a silverlight2 Class Library Project
Start vs2008, select new project, create the silverlight2 class library project, add a control class, and enter the new Project name: mybutton. This class can inherit from the control class or other classes such as contentcontrol and itemcontrol. We inherit from the button,CodeAs follows:
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;
NamespaceMybutton
{
Public ClassMybutton: button
{
}
}
Ii. handling such add events
Protected Override Void Onmouseleftbuttondown (mousebuttoneventargs E)
{
Base. Onmouseleftbuttondown (E );
E. Handled= False;
}
Protected Override VoidOnmouseleftbuttonup (mousebuttoneventargs E)
{
Base. Onmouseleftbuttonup (E );
E. Handled= False;
}
The complete code is as follows:
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;
NamespaceMybutton
{
Public ClassMybutton: button
{
Protected Override VoidOnmouseleftbuttondown (mousebuttoneventargs E)
{
Base. Onmouseleftbuttondown (E );
E. Handled= False;
}
Protected Override VoidOnmouseleftbuttonup (mousebuttoneventargs E)
{
Base. Onmouseleftbuttonup (E );
E. Handled= False;
}
}
}
3. compile and generate the project. For how to introduce and apply this custom button, see: "silverligth learning notes-how to solve the problem that the button does not respond to the mouseleftbuttondown and mouseleftbuttonup events ".
Go to: Silverlight Study Notes List
This articleProgramIt passes debugging in the silverlight2.0 and vs2008 environments. This article draws on some network materials and hopes to learn from them.
(For more information, see the source)