- 선택/미선택 가능한 컨트롤로 다른 언어에서 사용되는 RadioButton과 같습니다.
MainPage.xaml |
[그림 55-1] <Grid x:Name="LayoutRoot" Background="White"> <StackPanel x:Name="gg"> <TextBlock Text="어디사세요?"></TextBlock> <RadioButton x:Name="rdo1" Content="서울" IsChecked="True" Checked="rdo_Chk"></RadioButton> <RadioButton x:Name="rdo2" Content="한국" Checked="rdo_Chk"></RadioButton> <TextBlock x:Name="txtDomicile" Text="" FontSize="20"></TextBlock> <TextBlock Text="관심있는 프로그램 언어는??"></TextBlock> <RadioButton Content="C" IsChecked="True" GroupName="programe"> </RadioButton> <RadioButton Content="C#" GroupName="programe"></RadioButton> <RadioButton Content="SilverLight" GroupName="programe"></RadioButton> <TextBlock x:Name="txtPrograme" Text=""></TextBlock> </StackPanel> </Grid> |
MainPage.xaml.cs |
namespace RadioButton { public partial class MainPage : UserControl { public
MainPage() { InitializeComponent();
// RdoAdd(); } private
void RdoAdd() { System.Windows.Controls.RadioButton addRdo = new
System.Windows.Controls.RadioButton(); addRdo.Name = "add1"; addRdo.GroupName = "programe"; addRdo.Content = "VB"; gg.Children.Add(addRdo); System.Windows.Controls.RadioButton addRdo1 = new
System.Windows.Controls.RadioButton(); addRdo1.Name = "add2"; addRdo1.GroupName = "programe"; addRdo1.Content = "JAVA"; gg.Children.Add(addRdo1); } private
void rdo_Chk(object
sender, RoutedEventArgs e) { System.Windows.Controls.RadioButton rdo = sender as
System.Windows.Controls.RadioButton; if
(txtDomicile != null) { txtDomicile.Text = "사는곳이 " + rdo.Content as String; txtDomicile.Text += " 군요!"; } } } } |
결과화면 |
[그림 55-2] |
'Silverlight' 카테고리의 다른 글
57.SilverLight3 - ToolTip (0) | 2009.12.02 |
---|---|
56.SilverLight3 - CheckBox (0) | 2009.12.02 |
54.SilverLight3 - RepeatButton (0) | 2009.12.02 |
53.SilverLight3 - HyperlinkButton (0) | 2009.12.02 |
52.SilverLight3 - AttachedProperty (0) | 2009.12.02 |
Comments