private void OnSelectSearchItem() { IsPopupOpen = false; this.SearchText = string.Empty; if (this.SelectedCustomerID != 0) { var selectedCustomer = CustomerAction.GetCustomerByID(this.DBConnectionString, this.SelectedCustomerID.ToString( CultureInfo.InvariantCulture)); if (this.ContentViewModel != null && this.ContentViewModel.GetType() == typeof(AppointmentViewModel)) { var vm = ((AppointmentViewModel)this.ContentViewModel); vm.Entity.SelectedCustomer = selectedCustomer; return; } if (selectedCustomer != null) { this.ContentViewModel = null; this.ContentViewModel = new CustomerDetailViewModel(this.Messenger, this.UserLogin, selectedCustomer) { ParentViewModel = this }; GalaSoft.MvvmLight.Messaging.Messenger.Default.Send <IBaseViewModel>(this.ContentViewModel); } } }