/// <summary>
 /// note: this method is only for demonstration, you cannot use the same text box
 /// for both edit the current one and insert the new one
 /// because when the current text boxes loses focus, it will automatically update 
 /// the current one, and then after you press "Add", actually 
 /// the current one has already been modified into the same content as the newly added one
 /// </summary>
 private void btnAdd_Click(object sender, RoutedEventArgs e)
 {
     Person newOne = new Person
                         {
                             Name = tbxName.Text,
                             Age = int.Parse(tbxAge.Text)
                         };
     this.Persons.Add(newOne);
 }
        public PersonEditDlg()
        {
            m_localCopy = new Person();

            InitializeComponent();

            // note: my intention to use the code below is to check whether in design mode,
            // to set some fake data to be shown in the UI designer
            // however, it has no effect in the designer, maybe it only works in Blender
            // grid.DataContext = DesignerProperties.GetIsInDesignMode(this) ? new Person { Name = "test", Age = 10 } : person;

            grid.DataContext = m_localCopy;
        }
示例#3
0
 public void Add(Person person)
 {
     m_members.Add(person);
 }
示例#4
0
 public static void CopyFrom(this Person dest, Person src)
 {
     dest.Name = src.Name;
     dest.Age = src.Age;
 }