09-windowsPhone常用控件----单选按钮



代码:

<!--ContentPanel - 在此处放置其他内容-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="370*" />
                <ColumnDefinition Width="86*" />
            </Grid.ColumnDefinitions>
            <TextBlock Grid.ColumnSpan="2" Height="79" HorizontalAlignment="Left" Margin="66,56,0,0" Name="textBlock1" Text="请选择你喜欢的手机的品牌:" VerticalAlignment="Top" Width="343" />
            <RadioButton Content="A、苹果" Height="91" HorizontalAlignment="Left" Margin="96,122,0,0" Name="radioButton1" VerticalAlignment="Top" Width="224" Checked="radioButton1_Checked" GroupName="phone" />
            <RadioButton Content="B、三星" Height="73" HorizontalAlignment="Left" Margin="96,204,0,0" Name="radioButton2" VerticalAlignment="Top" Width="202" Checked="radioButton2_Checked" GroupName="phone" />
            <RadioButton Content="C、HTC" Height="73" HorizontalAlignment="Left" Margin="96,283,0,0" Name="radioButton3" VerticalAlignment="Top" Width="202" Checked="radioButton3_Checked" GroupName="phone" />
            <TextBlock Height="77" HorizontalAlignment="Left" Margin="50,417,0,0" Name="textBlock2" Text="您的选择是:" VerticalAlignment="Top" Width="149" />
            <TextBlock Height="59" HorizontalAlignment="Left" Margin="183,413,0,0" Name="textBlock3" Text="" VerticalAlignment="Top" Width="177" />
        </Grid>

//当选择的时候自动调用的方法
        private void radioButton1_Checked(object sender, RoutedEventArgs e)
        {
            //如果苹果被选中,在答案中显示苹果选项
            if (radioButton1.IsChecked == true) {
                textBlock3.Text = radioButton1.Content.ToString();
            }
        }

        private void radioButton2_Checked(object sender, RoutedEventArgs e)
        {
            //如果三星被选中,在答案中显示三星选项
            if (radioButton2.IsChecked == true)
            {
                textBlock3.Text = radioButton2.Content.ToString();
            }
        }

        private void radioButton3_Checked(object sender, RoutedEventArgs e)
        {
            //如果HTC被选中,在答案中显示HTC选项
            if (radioButton3.IsChecked == true)
            {
                textBlock3.Text = radioButton3.Content.ToString();
            }
        }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

会编程的阿强

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值