1
23 6 7 84 5 9 12 13 1410 11 15 8716 25 2617 18 19 20 21 22 23 24 27 31 3228 29 30 35 36 39 40 43 44 47 48 51 52 57 62 67 68 72 78 79 80 85 8673 74 75 76 77
---界面代码
1 namespace SecondProject 2 { 3 public partial class MainPage : PhoneApplicationPage 4 { 5 // Constructor 6 public MainPage() 7 { 8 InitializeComponent(); 9 } 10 11 private void myButton_Click(object sender, RoutedEventArgs e) 12 { 13 Agent at = new Agent(); 14 at.AgentName = myTextBox.Text; 15 if (myCheckBox.IsChecked==true) 16 { 17 at.IsUndercover=true; 18 } 19 else 20 { 21 at.IsUndercover=false; 22 } 23 //bool bl=at.IsUndercover; 24 //bool? bl=myCheckBox.IsChecked; 25 26 if (myRadioButton1.IsChecked == true) 27 { 28 at.Agency = myRadioButton1.Content.ToString(); 29 } 30 else if (myRadioButton2.IsChecked == true) 31 { 32 at.Agency = myRadioButton2.Content.ToString(); 33 } 34 else 35 { 36 at.Agency = myRadioButton3.Content.ToString(); 37 } 38 39 ListBoxItem lbi = (ListBoxItem)myListBox.SelectedItem; //获取ListBox中所选中的数据 40 at.Proficiency = (string)lbi.Content; 41 42 at.RecordCreatedDateTime = DateTime.Now; 43 44 at.Save(); 45 46 myTextBox.Text = ""; 47 48 myCheckBox.IsChecked = false; 49 50 myRadioButton1.IsChecked = false; 51 myRadioButton2.IsChecked = false; 52 myRadioButton3.IsChecked = false; 53 54 myListBox.SelectedItem = null; 55 56 } 57 } 58 }
---后台代码
1 namespace SecondProject 2 { 3 public class Agent 4 { 5 public string AgentName { get; set; } 6 public string Agency { get; set; } 7 public bool? IsUndercover { get; set; } 8 public string Proficiency { get; set; } 9 public DateTime RecordCreatedDateTime { get; set; } 10 11 12 public void Save() 13 { 14 this.AgentName = ""; 15 this.Agency = ""; 16 this.IsUndercover = false; 17 this.Proficiency = ""; 18 this.RecordCreatedDateTime = DateTime.Now; 19 } 20 } 21 22 23 }
Agent.cs代码
实现界面效果:
功能:点击“OK”按钮可以实现说有数据清空!