Windows Phone development (11): commonly used controls (below) Turn: http://blog.csdn.net/tcjiaan/article/details/7300085

Source: Internet
Author: User

Most WP controls can be inherited from Silverlight. Here I can only demonstrate some of them. For how to use other controls, refer to SDK instructions and Silverlight SDK documentation.

 

1. radiobutton control.

This is a single-choice control, which does not need to be explained. We have read more about it. If n is selected, whether the control is selected by the user is marked by the ischecked attribute.
In addition, note that the groupname attribute is used to input a group name, which is obtained by ourselves for grouping purposes. Because it is a single choice, A container may have n multiple radiobutton controls or multiple groups of radiobutton controls. Therefore, the group name plays a role, that is, only one group can be selected, for example, there is a group A, and a contains three radiobutton controls, which are respectively red, green, and yellow. Therefore, you can only select one of the three, and another group B, B has a radiobutton control, indicating the black light. Because it belongs to different groups, the red and black lights can be selected at the same time, or the green and black lights can be selected at the same time.
The following is an example:

 

[HTML]View plaincopyprint?

  1. <Radiobutton content = "pig head" Height = "115" horizontalalignment = "Left" margin = ", 50, 333 "name =" rad01 "verticalignment =" TOP "fontsize =" 43 "width =" "groupname =" g1 "Checked =" radiobtn_checked "/>
  2. <Radiobutton content = "" Height = "115" horizontalalignment = "Left" margin = "58,207, 333 "name =" rad02 "verticalignment =" TOP "fontsize =" 43 "width =" "groupname =" g1 "Checked =" radiobtn_checked "/>
  3. <Radiobutton content = "Dog Head" Height = "109" horizontalalignment = "Left" margin = "58,351, 333 "name =" rad03 "verticalignment =" TOP "fontsize =" 43 "width =" "groupname =" g1 "Checked =" radiobtn_checked "/>

 

[CSHARP]View plaincopyprint?

  1. Private void radiobtn_checked (Object sender, routedeventargs E)
  2. {
  3. Radiobutton RDB = E. originalsource as radiobutton;
  4. If (RDB! = NULL)
  5. {
  6. String MsgC = RDB. content as string;
  7. If (MsgC! = NULL)
  8. {
  9. MessageBox. Show ("You selected:" + MsgC );
  10. }
  11. }
  12. }

 

(Figure 1)

 

 

 

2. Image control.

This guy, you can guess what the name is. Yes, it is used to display images.

This control has two attributes to consider.
1. Source: supports both local images. Of course, it is generally better to compile images as resources. DLL is compressed into the xap package. At the same time, this attribute also supports Network images.
2. Stretch: how to place images in controls.

Example:

[HTML]View plaincopyprint?

  1. <Image horizontalalignment = "stretch" margin = "3" name = "image1" stretch = "fill" verticalignment = "stretch" Source = "/controlssample2; component/images/desert.jpg "/>

 

(Figure 2)

 

Next, let's take a look at the effect of using different values for the stretch attribute.
(Figure 3 and 4)

It may not be obvious. You can try it on your own.

 

 

3. ListBox control.

Even if you have never played WPF, you must have played a lot in winform. Set the itemssource attribute to bind data.

[HTML]View plaincopyprint?

  1. <ListBox horizontalalignment = "stretch" margin = "3" name = "listbox1" verticalignment = "stretch"/>

 

[CSHARP]View plaincopyprint?

  1. This. listbox1.itemssource = new string []
  2. {
  3. "Long Teng Hu Yue", "Hu tou shewei", "Ye gonghaolong", "water falls into stone"
  4. };

 

(Figure 5)

 

 

4. hyperlinkbutton control.

This control was also mentioned during the introduction of navigation. By the way, you can use it to easily implement page navigation. The example is omitted. It saves several hundred words.

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.