Windows Phone開發之控制項Grid,TextBox,TextBlock,RadioButton,CheckBox,ListBox簡介

來源:互聯網
上載者:User

多說無益,,代碼兩部分如下所示:

代碼如下:

<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="姓名:"                       HorizontalAlignment="Stretch"                        VerticalAlignment="Stretch"                       Grid.Column="0"                       Grid.Row="0"                       />            <TextBlock Name="textBlock1"                        Text="工作:"                       HorizontalAlignment="Stretch"                        VerticalAlignment="Stretch"                       Grid.Column="0"                        Grid.Row="1"                       />            <TextBlock Name="textBlock2"                        Text="哈哈你懂得:"                       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="奧特曼"                             />                <ListBoxItem Name="listBoxItem1"                             Content="孫悟空"                             />                <ListBoxItem Name="listBoxItem2"                             Content="關羽"                             />                <ListBoxItem Name="listBoxItem3"                             Content="周星星"                             />            </ListBox>            <Button Name="button"                    Content="Save"                    Grid.Column="3"                    Grid.Row="6"                    HorizontalAlignment="Stretch"                    VerticalAlignment="Stretch"                    /></Grid>

 以上控制項的後台操作:

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:兩個按鈕共用一個點擊事件
相似的事件操作可以採用該方法。  

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

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.