コード例 #1
0
        private void WinAddContact_ContactAddedCustom(object sender, ContactArgs e)
        {
            // first we should add new contact to database ==> Static.Contact
            // then referesh the listView Items

            Contact newContact = e.Contact;

            Statics.Contacts.Add(newContact);

            listViewContacts.Items.Clear();

            foreach (Contact contact in Statics.Contacts)
            {
                string contactList = string.Format("First Name: {0},Last Name: {1},Number: {2}", contact.FirsttName,
                                                   contact.LastName, contact.Number);
                listViewContacts.Items.Add(contactList);
            }
        }
コード例 #2
0
        private void buttonAddWithCustomEvent_Click(object sender, RoutedEventArgs e)
        {
            string firstName = textBoxFirstName.Text;
            string lastName  = textBoxLastName.Text;
            string number    = textBoxNumber.Text;


            Contact newContact = new Contact();

            newContact.FirsttName = firstName;
            newContact.LastName   = lastName;
            newContact.Number     = number;

            //Statics.Contacts.Add(newContact);

            //ContactArgs contactArgs=new ContactArgs(newContact);
            ContactArgs contactArgs = new ContactArgs();

            contactArgs.Contact = newContact;

            OnContactAddedCustom(contactArgs);
        }
コード例 #3
0
 protected virtual void OnContactAddedCustom(ContactArgs e)
 {
     ContactAddedCustom?.Invoke(this, e);
 }