private void button1_Click(object sender, RoutedEventArgs e)
{
String item = "";
textBlock2.Text = item;
if (checkBox1.IsChecked == true) {
item += checkBox1.Content.ToString();
textBlock2.Text = item;
} if(checkBox2.IsChecked==true){
item += checkBox2.Content.ToString();
textBlock2.Text = item;
}
if (checkBox3.IsChecked == true) {
item += checkBox3.Content.ToString();
textBlock2.Text = item;
}
}
定义了一个item的变量,每次在调用这个单击的方法的时候,都会进行清空操作。