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 ;}}