Exemplo n.º 1
0
 private void EditButtonOnClicked()
 {
     if (EditCommand != null && EditCommand.CanExecute(Product))
     {
         EditCommand.Execute(Product);
     }
 }
        /// <summary>
        /// load ItemInstance based on item selected from list, ie load shadow object
        /// </summary>
        /// <param name="selListItem"></param>
        protected override void loadSelectedItem(ItemResult selListItem)
        {
            if ((selListItem?.pk != null) && (selListItem.pk != Guid.Empty))
            {
                selectedItem = db.db.Load <Item>(selListItem.pk);

#if false
                // if not currently editing anything then we match current item, but
                // we don't update currentItem otherwise as may be a clone, etc.
                if (isDetailViewInActive && EditCommand.CanExecute(null))
                {
                    EditCommand.Execute(null);
                }
#else
                // update detail view immediately when a new item is selected
                // note this will loose changes for a clone
                if (currentItem != null && currentItem.IsChanged)
                {
                    var x = MessageBox.Show("Current item has been modified, do you wish to save changes?", $"Changes to {currentItem.displayName} will be lost!", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes);
                    if (x == MessageBoxResult.Yes)
                    {
                        if (SaveCommand.CanExecute(null))
                        {
                            SaveCommand.Execute(null);
                        }
                    }
                }
                if (EditCommand.CanExecute(null))
                {
                    EditCommand.Execute(null);
                }
#endif
            }
            else
            {
                selectedItem = null;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// load ItemResult based on item selected from list, ie load shadow object
        /// </summary>
        /// <param name="selListItem"></param>
        protected override void loadSelectedItem(ItemResult selListItem)
        {
            try
            {
                if (currentItem != null)
                {
                    currentItem.PropertyChanged -= CurrentItem_PropertyChanged;
                }

                if ((selListItem?.pk != null) && (selListItem.pk != Guid.Empty))
                {
                    selectedItem = db.db.Load <ItemType>(selListItem.pk);

#if false
                    // if not currently editing anything then we match current item, but
                    // we don't update currentItem otherwise as may be a clone, etc.
                    if (isDetailViewInActive && EditCommand.CanExecute(null))
                    {
                        EditCommand.Execute(null);
                    }
#else
                    // update detail view immediately when a new item is selected
                    // note this will loose changes for a clone
                    if (currentItem != null && currentItem.IsChanged)
                    {
                        var x = MessageBox.Show("Current item has been modified, do you wish to save changes?", $"Changes to {currentItem.displayName} will be lost!", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes);
                        if (x == MessageBoxResult.Yes)
                        {
                            if (SaveCommand.CanExecute(null))
                            {
                                SaveCommand.Execute(null);
                            }
                        }
                    }
                    if (EditCommand.CanExecute(null))
                    {
                        EditCommand.Execute(null);
                    }

                    /*
                     * currentItem = selectedItem;  //DoEdit();
                     *                           // Note: need same object so changes triggered via items bound to selectedListItem will show in detail view
                     * selListItem.entity = currentItem;
                     */
#endif
                }
                else
                {
                    selectedItem = null;
                }

                if (currentItem != null)
                {
                    currentItem.PropertyChanged += CurrentItem_PropertyChanged;
                }
                // flag other items that may change when selected item changes
                RaisePropertyChanged(nameof(HasMultipleImages));

                // select first image (or clear)
                currentImageIndex = 0;
            }
            catch (Exception e)
            {
                logger.Error(e, $"Exception in loadSelectedItem - {e.Message}");
                throw;
            }
        }
 private bool CanEdit()
 {
     return(EditCommand != null && EditCommand.CanExecute(Text));
 }