Ejemplo n.º 1
0
        static void OnIsPopupOpenChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            ConfigButton button = obj as ConfigButton;

            if (button != null)
            {
                if ((bool)e.NewValue)
                {
                    if (currentlyOpenConfigButton != null)
                    {
                        currentlyOpenConfigButton.IsPopupOpen = false;
                    }
                    currentlyOpenConfigButton = button;

                    if (button.popup != null)
                    {
                        button.popup.IsOpen = true;
                    }
                }
                else
                {
                    if (button.popup != null)
                    {
                        button.popup.IsOpen = false;
                    }

                    if (currentlyOpenConfigButton == button)
                    {
                        currentlyOpenConfigButton = null;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        static void BindCommitControlToValidatedProperty(FrameworkElement element)
        {
            ConfigButton button = element.FindParent <ConfigButton>();

            if (button != null)
            {
                element.SetBinding(IsEnabledProperty, new Binding {
                    Source = button, Path = new PropertyPath(CanCommitProperty)
                });
            }
        }
Ejemplo n.º 3
0
        void OnButtonClick(object sender, RoutedEventArgs e)
        {
            // If any button click events escape to this level, don't let them cause this button to be "clicked"...
            if (e.OriginalSource != this)
            {
                var dependencyObj = e.OriginalSource as DependencyObject;

                if (dependencyObj != null)
                {
                    // ...unless they indicate dismiss/commit via attached properties
                    bool commits = ConfigButton.GetCommitsConfigButton(dependencyObj);

                    if (commits || ConfigButton.GetDismissesConfigButton(dependencyObj))
                    {
                        this.RaiseEvent(new ClosePopupEventArgs(this, commits));
                    }
                }

                e.Handled = true;
            }
        }
Ejemplo n.º 4
0
        static void AddOrRemoveValidatedElement(FrameworkElement element, bool add)
        {
            ConfigButton button = element.FindParent <ConfigButton>();

            if (button != null)
            {
                if (add)
                {
                    button.validatedElements.Add(element);
                }
                else
                {
                    button.validatedElements.Remove(element);
                }

                if (button.validatedElements.Count > 0)
                {
                    var mb = new MultiBinding {
                        Converter = HasErrorsToCanCommitConverter.Instance
                    };

                    foreach (var validatedElement in button.validatedElements)
                    {
                        mb.Bindings.Add(new Binding {
                            Source = validatedElement, Path = new PropertyPath(Validation.HasErrorProperty)
                        });
                    }

                    button.SetBinding(CanCommitProperty, mb);
                }
                else
                {
                    button.CanCommit = true;
                }
            }
        }
        static void OnIsPopupOpenChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            ConfigButton button = obj as ConfigButton;

            if (button != null)
            {
                if ((bool)e.NewValue)
                {
                    if (currentlyOpenConfigButton != null)
                    {
                        currentlyOpenConfigButton.IsPopupOpen = false;
                    }
                    currentlyOpenConfigButton = button;

                    if (button.popup != null)
                    {
                        button.popup.IsOpen = true;
                    }
                }
                else
                {
                    if (button.popup != null)
                    {
                        button.popup.IsOpen = false;
                    }

                    if (currentlyOpenConfigButton == button)
                    {
                        currentlyOpenConfigButton = null;
                    }
                }
            }
        }