Usage of usercontrol in Windows Phone development

Source: Internet
Author: User

Usercontrol usage:
When developing a project, mainpanel usually loads many controls, but it is not only not beautiful but also very difficult to maintain when there are more controls. Userconrtol can not only customize controls, but also load a layout control to the main interface, which facilitates maintenance and clarity. Add a new project> Windows Phone user control. You can define and use the control at will in <grid... of the new usercontrol (maincontrol user control name.

The content of this article is as follows:
Http://blog.csdn.net/fengyun1989/article/details/7341747#reply
Http://www.cnblogs.com/wangshuai/archive/2010/08/24/1807624.html

The textures are as follows:

<! -- Contentpanel-place other content here --> <grid X: Name = "contentpanel" grid. row = "1" margin = "12, 0, 12, 0"> <stackpanel name = "mystackpanel" verticalignment = "stretch" horizontalalignment = "stretch"> <mycontrol: maincontrol temp = "7℃ ~ 11 ℃ "week =" Sunday "width =" 300 "Height =" 200 "horizontalalignment =" right "imageuri ="/myweatherforecast; component/images/sunday.jpg "/> <mycontrol: maincontrol temp = "7℃ ~ 11 ℃ "week =" Monday "width =" 300 "Height =" 200 "horizontalalignment =" right "imageuri ="/myweatherforecast; component/images/cloudy.jpg "/> </stackpanel> </GRID>

Note:
According to the picture, you can know that the custom maincontrol control is under the mycontrols folder. When using this control on the main page page1, you need to add a reference to this project.

The method is as follows:
Xmlns: mycontrol = "CLR-namespace: myweatherforecast"
Mycontrol is the reference name of the custom control, and myweatherforecast is the reference nameProgramProject name.
If the referenced control is in another project, xmlns: mycontrol = "CLR-namespace: otherproject. filefolder; Assembly = maincontrol"
CLR-namespace: otherproject. filefolder is equivalent to the path, and assembly = maincontrol indicates the custom control.

Usercontrol defines the following member variables:

Private string _ weekday; Public String week {get {return _ weekday;} set {_ weekday = value; this. weekday. TEXT = value ;}} private string _ temp; Public String temp {get {return _ temp;} set {_ temp = value; this. temp. TEXT = value ;}} private string _ imageuri; Public String imageuri {get {return _ imageuri;} set {_ imageuri = value; bitmapimage image = new bitmapimage (New uri (value, urikind. relative); this. myimage. source = image ;}}

 

 

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.