Beispiel #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];
                    }
                }
            }
        }
Beispiel #2
0
 public FocusingInvalidControlEventArgs(ValidationSummaryItem item, ValidationSummaryItemSource target)
 {
     this.Handled = false;
     this.Item    = item;
     this.Target  = target;
 }
 public ValidationSummaryItem(string message, string messageHeader, ValidationSummaryItemType itemType, ValidationSummaryItemSource source, object context)
 {
     this.MessageHeader = messageHeader;
     this.Message       = message;
     this.ItemType      = itemType;
     this.Context       = context;
     this.Sources       = new System.Collections.ObjectModel.ObservableCollection <ValidationSummaryItemSource>();
     if (source != null)
     {
         this.Sources.Add(source);
     }
 }
Beispiel #4
0
 private static int FindMatchingErrorSource(IList <ValidationSummaryItemSource> sources, ValidationSummaryItemSource sourceToFind)
 {
     if (sources != null)
     {
         for (var i = 0; i < sources.Count; i++)
         {
             if (sources[i].Equals(sourceToFind))
             {
                 return(i);
             }
         }
     }
     return(-1);
 }