Silverlight button control completion design-Silverlight (silver light) Learning (2)

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.