コード例 #1
0
        private void EditContact_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            ContactWindow contactWindow = new ContactWindow(Dealer.Contacts.First(x => x.Id == (long)(Contacts.SelectedItem as TextBlock).Tag).Clone());

            if ((bool)contactWindow.ShowDialog(this))
            {
                Dealer.Contacts[Dealer.Contacts.FindIndex(x => x.Id == contactWindow.Contact.Id)] = contactWindow.Contact;
                UpdateContacts();
                Contacts.SelectItem(Contacts.Items.FirstOrDefault <TextBlock>(x => (long)x.Tag == contactWindow.Contact.Id));
            }
        }
コード例 #2
0
        private void AddContact_Click(object sender, RoutedEventArgs e)
        {
            ContactWindow contactWindow = new ContactWindow();

            if ((bool)contactWindow.ShowDialog(this))
            {
                contactWindow.Contact.Id = Dealer.Contacts.Count != 0 ? Dealer.Contacts.Max(x => x.Id) + 1 : 1;
                Dealer.Contacts.Add(contactWindow.Contact);
                UpdateContacts();
                Contacts.SelectItem(Contacts.Items.FirstOrDefault <TextBlock>(x => (long)x.Tag == contactWindow.Contact.Id));
            }
        }