Article 1 Article A button is designed. Unfortunately, Chinese characters cannot be displayed, which involves the font copyright issue. I think Microsoft is afraid of infringement like the wow of blizzard. There are several solutions on the Internet, including downloading fonts and designing fonts in word. This is not within the scope of my discussion. I just want to add the button and click the event. I want to solve the problem of supporting Chinese characters after the official version is released.
In Asp.net, There Are Click events for buttons. In The XAML interface, how does one trigger the mouse click event? In fact, there are
Mouseenter mouseleave mouseleftbuttondown mouseleftbuttonup Event
When the mouseleftbuttonup event of the mouse is triggered, we can call the event we wrote to implement the left mouse click event.
CodeThe snippets are as follows:
Public Event Eventhandler click;
// Trigger Click Event
Protected Void Raiseclick ()
{
If (Click ! = Null )
{
Click (This,Null);
}
}
Void Actcontrol_mouseleftbuttonup ( Object Sender, mouseeventargs E)
{
Releasemousecapture ();
Raiseclick ();
}
In this way, the click event is added to the button control.
Let's go back to the wowmovie project in the previous article and add the following code in page. Xmal. CS: Public Void Page_loaded ( Object O, eventargs E)
{
Double Top = 100 ;
Double Left = 20 ;
Buttoncontrol txtbox = New Buttoncontrol ();
Txtbox. buttontext = " Hello! " ;
Txtbox. setvalue < Double > (Canvas. topproperty, top );
Txtbox. setvalue < Double > (Canvas. leftproperty, left );
Txtbox. Click + = New Eventhandler (txtbox_click );
This . Children. Add (txtbox );
}
Void Txtbox_click ( Object Sender, eventargs E)
{
Buttoncontrol BT=SenderAsButtoncontrol;
Bt. buttontext= "You click me";
}
The effect is as follows:
Click it to make it look like this.