<TabControl>
<TabItem Header="Setting">
<Grid>
</Grid>
</TabItem>
<TabItem Header="WebBrowser">
<Grid>
</Grid>
</TabItem>
</TabControl>
<GroupBox Header="Option">
<Grid>
<RadioButton/>
<RadioButton/>
</Grid>
</GroupBox>
더블 클릭시 Checked 이벤트 메서드가 자동 생성됨
<RadioButton x:Name="radioButton1"
Content="RadioButton1"
IsChecked="True"
Checked="radioButton1_Checked"/>
private void radioButton1_Checked(object sender, RoutedEventArgs e)
{
if(radioButton1.IsChecked == true)
{
// 라디오 버튼이 체크되었을 경우 실행할 코드
}
}
더블 클릭시 Checked 이벤트 메서드가 자동 생성됨
<CheckBox x:Name="checkBox1"
Content="CheckBox1"
IsChecked="False"
Checked="checkBox1_Checked"/>
<ComboBox x:Name="comboBox">
<ComboBoxItem Content="Coffee"/>
<ComboBoxItem Content="Milk"/>
<ComboBoxItem Content="Hot Choco"/>
</ComboBox>
comboBox.Items.Add("Tomato Juice");
ComboBoxItem item = (ComboBoxItem)comboBox.SelectedValue;
string item_name = item.Content.ToString();
comboBox.Items.Remove(comboBox.Items.IndexOf(comboBox.SelectedItem));
<ListBox x:Name="listBox">
<ListBoxItem>곰</ListBoxItem>
<ListBoxItem>멍멍이</ListBoxItem>
</ListBox>
listBox.Items.Add("악어");
리스트 박스를 포함한 대부분의 컨트롤들은 데이터 템플릿에 데이터를 바인딩(Binding)하여 사용 가능
<ListBox x:Name="listBox"> <ListBox.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="100"/> </Grid.ColumnDefinitions> <TextBlock Text="{Binding Name}"/> <ProgressBar Grid.Column="1" Minimum="0" Maximum="100" Value="{Binding Percent}"/> </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListBox>
class Animals { public string Name { get; set; } public int Percent { get; set; } } List<Animals> animals = new List<Animals>(); animals.Add(new Animals() { Name = "하마", Percent = 10 }); listBox.ItemsSource = animals;
슬라이더
<Slider x:Name="slider1" Maximum="100" TickPlacement="BottomRight" TickFrequency="5" IsSnapToTickEnabled="True"/>
private void slider1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) { label_sliderValue.Content = slider1.Value.ToString(); }
웹 브라우저
<WebBrowser x:Name="WebBrowser1"/>
WebBrowser1.Navigate("http://www.naver.com"); WebBrowser1.GoBack(); //뒤로가기 WebBrowser1.GoForward(); //앞으로가기