コード例 #1
0
 private void NewPartnerFormClick(object sender, RoutedEventArgs e)
 {
     if (DataContext is PartnersVM)
     {
         PartnersVM partnersVM = DataContext as PartnersVM;
         if (partnersVM != null)
         {
             PartnerFormVM partnerForm = new PartnerFormVM {
                 ChosenPartner = new Partner(), IsEdit = false
             };
             PartnerFormWindow formWindow = new PartnerFormWindow {
                 DataContext = partnerForm
             };
             partnerForm.ValuesTransmission();
             formWindow.ShowDialog();
             partnersVM.RefreshList();
         }
     }
     else
     {
         ContactsVM contactsVM = DataContext as ContactsVM;
         if (contactsVM != null)
         {
             ContactFormVM contactForm = new ContactFormVM {
                 ChosenContact = new Contact(), IsEdit = false
             };
             ContactFormWindow formWindow = new ContactFormWindow {
                 DataContext = contactForm
             };
             formWindow.ShowDialog();
             contactsVM.RefreshList();
         }
     }
 }
コード例 #2
0
 private void PartnerFormClick(object sender, MouseButtonEventArgs e)
 {
     if (DataContext is PartnersVM)
     {
         PartnersVM partnersVM = DataContext as PartnersVM;
         if (partnersVM != null && partnersVM.SelectedPartner != null)
         {
             PartnerFormVM partnerForm = new PartnerFormVM {
                 ChosenPartner = partnersVM.SelectedPartner, IsEdit = true
             };
             PartnerFormWindow formWindow = new PartnerFormWindow {
                 DataContext = partnerForm
             };
             partnerForm.ValuesTransmission();
             formWindow.ShowDialog();
         }
     }
     else
     {
         ContactsVM contactsVM = DataContext as ContactsVM;
         if (contactsVM != null && contactsVM.SelectedPartner != null && contactsVM.IsPartnerAdd != null)
         {
             contactsVM.AddContact();
             contactsVM.PartnersList.Remove(contactsVM.SelectedPartner);
             return;
         }
         if (contactsVM != null && contactsVM.SelectedPartner != null)
         {
             ContactFormVM contactForm = new ContactFormVM {
                 ChosenContact = contactsVM.SelectedPartner, IsEdit = true
             };
             ContactFormWindow formWindow = new ContactFormWindow {
                 DataContext = contactForm
             };
             contactForm.CopyContact();
             formWindow.ShowDialog();
         }
     }
 }