Wpf sdk research intro (4) quickstart4

Source: Internet
Author: User
Quickstart4
This sample shows you how to implement a button with an associated Click Event Handler.
This example describes how to bind background events to a XAML button.

XAML Code : < Page
Xmlns = " Http://schemas.microsoft.com/winfx/2006/xaml/presentation "
Xmlns: x = " Http://schemas.microsoft.com/winfx/2006/xaml "
X: Class = " Quickstart_4.page1 " >
< Stackpanel >
< Button horizontalalignment = " Left "
Width = " 100 "
Margin = " 10, 10, 10 "
Click = " Handleclick "
Name = " Button1 " > Click me </ Button >
</ Stackpanel >
</ Page >

Background code: Namespace Quickstart_4
{
Public   Partial   Class Page1: Page
{
Void Handleclick ( Object Sender, routedeventargs E)
{
Button1.content= "Hello World";
}
}
}

The analysis is as follows:
The page tag of the XAML code, X: class = "quickstart_4.page1", specifies that the XAML file will be compiled into quickstart_4.page1 (The XAML file without this attribute is dynamically compiled at runtime ). Use the Click Event of the button to specify the corresponding method in the background.
Note that the background code event method uses the routedeventargs parameter, which involves the new event mechanism in WPF.

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.