Simple use of usercontrol in Windows Phone 7

Source: Internet
Author: User

On the usercontrol page:

A button is added to XAML with a click event button_click.

 
<Grid X: Name ="Layoutroot">
<Button click ="Button_click"Style ="{Staticresource buttonstyle1}">
<Button. Background>
<Imagebrush imagesource ="Applicationicon.png"> </Imagebrush>
</Button. Background>
</Button>
</GRID>

CSCode:

Public EventEventhandler <routedeventargs> goclick;
Private VoidButton_click (ObjectSender, routedeventargs E)
{
VaRH = goclick;
If(H! =Null)
{
H (This, E );
}
}

On the page that calls usercontrol, The XAML:

Introduce namespace:

 
Xmlns: My ="CLR-namespace: yourusercontrolsolutionnamehere"

Add usercontrol:

<My: yourusercontrolclassname name ="Usercontrol"Width ="100"Height ="100"> </My: yourusercontrolclassname>

The CS Code defines and processes click events:

Usercontrol. goclick + =NewEventhandler <routedeventargs> (usercontrol_goclick );
VoidUsercontrol_goclick (ObjectSender, routedeventargs E)
{
Navigationservice. navigate (NewUri ("/Pivotpage1.xaml", Urikind. Relative ));
}

OK. The jump ends.

Related Article

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.