Windows Phone development controls: grid, Textbox, textblock, radiobutton, checkbox, and ListBox

Source: Internet
Author: User

The Code is as follows:


The Code is as follows:


<Grid x: Name = "ContentPanel" Grid.Row = "1" Margin = "12,0,12,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width = "160 *" />
                <ColumnDefinition Width = "10" />
                <ColumnDefinition Width = "250 *" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height = "70" />
                <RowDefinition Height = "70" />
                <RowDefinition Height = "70" />
                <RowDefinition Height = "70" />
                <RowDefinition Height = "40" />
                <RowDefinition Height = "120" />
                <RowDefinition Height = "70" />
                <RowDefinition Height = "70" />
            </Grid.RowDefinitions>
            <TextBlock Name = "textBlock0"
                       Text = "Name:"
                       HorizontalAlignment = "Stretch"
                       VerticalAlignment = "Stretch"
                       Grid.Column = "0"
                       Grid.Row = "0"
                       />
            <TextBlock Name = "textBlock1"
                       Text = "Work:"
                       HorizontalAlignment = "Stretch"
                       VerticalAlignment = "Stretch"
                       Grid.Column = "0"
                       Grid.Row = "1"
                       />
            <TextBlock Name = "textBlock2"
                       Text = "haha you know:"
                       HorizontalAlignment = "Stretch"
                       VerticalAlignment = "Stretch"
                       Grid.Column = "0"
                       Grid.Row = "4"
                       />
            <TextBlock Name = "textBlock3"
                       Text = "1"
                       HorizontalAlignment = "Stretch"
                       VerticalAlignment = "Stretch"
                       Grid.Column = "0"
                       Grid.Row = "5"
                       />
            <TextBox Name = "textBox_Nam2e"
                     Text = ""
                     Grid.Column = "2"
                     Grid.Row = "0"
                     HorizontalAlignment = "Stretch"
                     VerticalAlignment = "Stretch"
                     />
            
            <CheckBox Name = "checkBox1"
                      Content = ""
                      Grid.Column = "2"
                      Grid.Row = "1"
                      HorizontalAlignment = "Stretch"
                      VerticalAlignment = "Stretch"
                      />
            <RadioButton Name = "radioButton1"
                         GroupName = "myGroup"
                         Content = "FBI"
                         Grid.Column = "2"
                         Grid.Row = "2"
                         HorizontalAlignment = "Stretch"
                         VerticalAlignment = "Stretch"
                         />
            <RadioButton Name = "radioButton2"
                         GroupName = "myGroup"
                         Content = "CIA"
                         Grid.Column = "2"
                         Grid.Row = "3"
                         HorizontalAlignment = "Stretch"
                         VerticalAlignment = "Stretch"
                         />
            <ListBox Name = "myListBox"
                     Grid.Column = "0"
                     Grid.Row = "5"
                     Grid.ColumnSpan = "3"
                     HorizontalAlignment = "Stretch"
                     VerticalAlignment = "Stretch">
                <ListBoxItem Name = "listBoxItem0"
                             Content = "Ultraman"
                             />
                <ListBoxItem Name = "listBoxItem1"
                             Content = "Sun Wukong"
                             />
                <ListBoxItem Name = "listBoxItem2"
                             Content = "Guan Yu"
                             />
                <ListBoxItem Name = "listBoxItem3"
                             Content = "周 星"
                             />
            </ ListBox>
            <Button Name = "button"
                    Content = "Save"
                    Grid.Column = "3"
                    Grid.Row = "6"
                    HorizontalAlignment = "Stretch"
                    VerticalAlignment = "Stretch"
                    />
</ Grid> 

Background operations of the preceding controls:


if (checkBox1.IsChecked==true) {
                MessageBox.Show("this.checkBox1.IsChecked");
            }
            if (radioButton1.IsChecked == true) {
                MessageBox.Show("FBI");
            }
            foreach (ListBoxItem myList in myListBox.Items) {
                if (myList.IsSelected) {
                    MessageBox.Show(myList.Name+"||"+myList.Content);
                }
            }

P.s: two buttons share one click event.
This method can be used for similar event operations.


 private void button_Click(object sender, RoutedEventArgs e){
   Button myButton=(Button)sender;
   textBlock.Text=myButton.Name;
   }  

 

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.