Windows Phone Development (11): Common Controls (bottom)

Source: Internet
Author: User
Tags silverlight

Most of the WP controls can be inherited from Silverlight, and I can only take part in the demo, and for other controls, refer to the SDK instructions and the Silverlight SDK documentation.

One, RadioButton controls.


This is a radio control, do not explain more, we see more, n Select 1, whether the control is selected by the user, marked by the IsChecked property.
In addition, one thing to note is the GroupName property, which enters a group name, which we take for the purpose of grouping, because it is a single radio, so there may be n multiple RadioButton controls in a container or multiple sets of RadioButton controls, so Group names play a role, that is, the same group can only choose one, for example, there is a group A,a contains 3 RadioButton controls, respectively, red, green, yellow lights, so, among the three you can only select one, and there is a group of b,b in a RadioButton control, Indicates a black light. Because they belong to different groups, red and black lights can be selected at the same time, or the green and black lights can be selected at the same time.
Let's look at an example:

    1. <radiobutton content= "Pig head" height= "horizontalalignment=" "left" margin= "58,50,0,0" name= "RAD01" Verticalalignment= "Top" fontsize= "width=" 333 "groupname=" G1 "checked=" radiobtn_checked "/>
    2. <radiobutton content= "Bull head" height= "horizontalalignment=" "left" margin= "58,207,0,0" name= "RAD02" Verticalalignment= "Top" fontsize= "width=" 333 "groupname=" G1 "checked=" radiobtn_checked "/>
    3. <radiobutton content= "dog Head" height= "109" horizontalalignment= "left" margin= "58,351,0,0" name= "RAD03" Verticalalignment= "Top" fontsize= "width=" 333 "groupname=" G1 "checked=" radiobtn_checked "/>


    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 have selected:"  +  MSGC);   
    10.         }  
    11.      }  
    12. }  


(Fig. 1)

Second, the image control.


This guy, look at his name and you can guess what it's doing. Oh, yes, it is used to display pictures.

The control has two properties to be concerned about.
1, Source: Support The local image, of course, the picture is generally compiled into a good resource, so that it and the. dll is compressed into the XAP package, and this property also supports network pictures.
2, Stretch: How the picture is placed in the control.

As in the following example:

    1. <image horizontalalignment= "Stretch" margin= "3" name= "Image1" stretch= "Fill" verticalalignment= "Stretch" source= " /controlssample2;component/images/desert.jpg "/>


(Fig. 2)

Let's take a look at the effect of the stretch property on the different values.
(Fig. 3, 4)

It may not be obvious that you can try it yourself.

Third, the ListBox control.


Even if you haven't played WPF, you must have played a lot in WinForm. Bind data Set the ItemsSource property.

    1. <listbox horizontalalignment= "Stretch" margin= "3" name= "ListBox1" verticalalignment= "Stretch"/>


    1. This.listBox1.ItemsSource = new string[]
    2. {
    3. "Hustle", "out of the box", "They applying", "the Bottom"
    4. };

(Fig. 5)

Four, Hyperlinkbutton controls.


In the introduction of the navigation also mentioned this control, on, with it can be easily implemented page navigation, example is omitted, hehe, and save hundreds of words.

Windows Phone Development (11): Common Controls (bottom)

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.