Пример #1
0
        private void ExecuteClick(object sender)
        {
            var box = sender as ListBox;

            if (box != null)
            {
                var selectedItem = box.SelectedItem as ValidationSummaryItem;
                if ((selectedItem != null) && this.FocusControlsOnClick)
                {
                    if (selectedItem.Sources.Count == 0)
                    {
                        this._currentValidationSummaryItemSource = null;
                    }
                    else if (FindMatchingErrorSource(selectedItem.Sources, this._currentValidationSummaryItemSource) < 0)
                    {
                        this._currentValidationSummaryItemSource = selectedItem.Sources[0];
                    }
                    var e = new FocusingInvalidControlEventArgs(selectedItem, this._currentValidationSummaryItemSource);
                    this.OnFocusingInvalidControl(e);
                    var peer = FrameworkElementAutomationPeer.FromElement(this) as ValidationSummaryAutomationPeer;
                    if ((peer != null) && AutomationPeer.ListenerExists(AutomationEvents.InvokePatternOnInvoked))
                    {
                        peer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked);
                    }
                    if ((!e.Handled && (e.Target != null)) && (e.Target.Control != null))
                    {
                        e.Target.Control.Focus();
                    }
                    if (selectedItem.Sources.Count > 0)
                    {
                        var num = FindMatchingErrorSource(selectedItem.Sources, e.Target);
                        num = (num < 0) ? 0 : (++num % selectedItem.Sources.Count);
                        this._currentValidationSummaryItemSource = selectedItem.Sources[num];
                    }
                }
            }
        }
Пример #2
0
        protected virtual void OnFocusingInvalidControl(FocusingInvalidControlEventArgs e)
        {
            var focusingInvalidControl = this.FocusingInvalidControl;

            focusingInvalidControl?.Invoke(this, e);
        }