Exemplo n.º 1
0
        public void SelectImageButton_Clicked(object sender, RoutedEventArgs e)
        {
            if (DataContext is null)
            {
                return;
            }
            ViewModel vm     = DataContext as ViewModel ?? throw new NullReferenceException();
            var       picker = new ImagePickerWindow(vm.SetImageHash);

            picker.ShowDialog();
        }
Exemplo n.º 2
0
        // Open the dialog to pick image, when the dropdown button is pressed
        public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource)
        {
            ImagePickerWindow window = new ImagePickerWindow(propertyValue.Value as BitmapImage);

            if (window.ShowDialog().Equals(true))
            {
                var       ownerActivityConverter = new ModelPropertyEntryToOwnerActivityConverter();
                ModelItem activityItem           = ownerActivityConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), false, null) as ModelItem;
                using (ModelEditingScope editingScope = activityItem.BeginEdit())
                {
                    propertyValue.Value = window.TheImage;
                    editingScope.Complete(); // commit the changes

                    var control = commandSource as Control;
                    var oldData = control.DataContext;
                    control.DataContext = null;
                    control.DataContext = oldData;
                }
            }
        }
Exemplo n.º 3
0
        // Open the dialog to pick image, when the dropdown button is pressed
        public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource)
        {
            ImagePickerWindow window = new ImagePickerWindow(propertyValue.Value as BitmapImage);
            if (window.ShowDialog().Equals(true))
            {
                var ownerActivityConverter = new ModelPropertyEntryToOwnerActivityConverter();
                ModelItem activityItem = ownerActivityConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), false, null) as ModelItem;
                using (ModelEditingScope editingScope = activityItem.BeginEdit())
                {
                    propertyValue.Value = window.TheImage;
                    editingScope.Complete(); // commit the changes

                    var control = commandSource as Control;
                    var oldData = control.DataContext;
                    control.DataContext = null;
                    control.DataContext = oldData;
                }
            }
        }