private void ShowContextMenu(FrameworkElement sender, ContactViewModel selected) { var builder = new ContextMenuBuilder(null); if (selected != null) { builder.New("_Contact details...").Handler(() => { EditSelectedContact(); }).End(); builder.New("_Delete contact").Handler(() => { DeleteContact(selected); }).End(); builder.New("_Loans...").Handler(() => { ShowLoansForContact(selected); }).End(); } if (builder.HasItems) { builder.Separator(); } builder.New("Add new contact...").Handler(() => { AddNewContact(); }).End(); if (builder.HasItems) { sender.ContextMenu = builder.ContextMenu; } }
void ContactDetails_ChangeContainerSet() { Contact model = null; if (_contactId < 0) { model = new Contact(); model.ContactID = _contactId; RegisterUniquePendingChange(new InsertContactCommand(model)); } else { var service = new LoanService(User); model = service.GetContact(_contactId); } _viewModel = new ContactViewModel(model); if (model != null && !string.IsNullOrEmpty(model.StreetAddress)) { if (model.StreetAddress.Equals(model.PostalAddress, StringComparison.CurrentCultureIgnoreCase)) { _viewModel.PostalSameAsStreet = true; } } tabContact.AddTabItem("Traits", new TraitControl(User, TraitCategoryType.Contact, _viewModel)); tabContact.AddTabItem("Notes", new NotesControl(User, TraitCategoryType.Contact, _viewModel)); txtInstituion.BindUser(User, "tblContact", "vchrInstitution"); _viewModel.DataChanged += new DataChangedHandler(viewModel_DataChanged); this.DataContext = _viewModel; this.WindowTitle = string.Format("Contact detail: {0} [{1}]", _viewModel.FullName, _viewModel.ContactID); }
void _page_ContextMenuRequested(FrameworkElement sender, ContactViewModel obj) { ShowContextMenu(sender, obj); }
public ContactTooltipContent(int contactId, ContactViewModel viewModel) : base(contactId, viewModel) { }