Provides data for the E:System.Windows.Controls.AutoCompleteBox.Populated event.
Inheritance: RoutedEventArgs
コード例 #1
0
        /// <summary>
        /// Notifies the
        /// <see cref="T:System.Windows.Controls.AutoCompleteBox" /> that the
        /// <see cref="P:System.Windows.Controls.AutoCompleteBox.ItemsSource" />
        /// property has been set and the data can be filtered to provide
        /// possible matches in the drop-down.
        /// </summary>
        /// <remarks>
        /// Call this method when you are providing custom population of 
        /// the drop-down portion of the AutoCompleteBox, to signal the control 
        /// that you are done with the population process. 
        /// Typically, you use PopulateComplete when the population process 
        /// is a long-running process and you want to cancel built-in filtering
        ///  of the ItemsSource items. In this case, you can handle the 
        /// Populated event and set PopulatingEventArgs.Cancel to true. 
        /// When the long-running process has completed you call 
        /// PopulateComplete to indicate the drop-down is populated.
        /// </remarks>
        public void PopulateComplete()
        {
            // Apply the search filter
            RefreshView();

            // Fire the Populated event containing the read-only view data.
#if SILVERLIGHT
            PopulatedEventArgs populated = new PopulatedEventArgs(new ReadOnlyCollection<object>(_view));
#else
            PopulatedEventArgs populated = new PopulatedEventArgs(new ReadOnlyCollection<object>(_view), PopulatedEvent);
#endif
            OnPopulated(populated);

            if (SelectionAdapter != null && SelectionAdapter.ItemsSource != _view)
            {
                SelectionAdapter.ItemsSource = _view;
            }

            bool isDropDownOpen = _userCalledPopulate && (_view.Count > 0);
            if (isDropDownOpen != IsDropDownOpen)
            {
                _ignorePropertyChange = true;
                IsDropDownOpen = isDropDownOpen;
            }
            if (IsDropDownOpen)
            {
                OpeningDropDown(false);
                if (DropDownPopup != null)
                {
                    DropDownPopup.Arrange();
                }
            }
            else
            {
                ClosingDropDown(true);
            }

            UpdateTextCompletion(_userCalledPopulate);
        }
コード例 #2
0
        /// <summary>
        /// Raises the
        /// <see cref="E:System.Windows.Controls.AutoCompleteBox.Populated" />
        /// event.
        /// </summary>
        /// <param name="e">A
        /// <see cref="T:System.Windows.Controls.PopulatedEventArgs" />
        /// that contains the event data.</param>
        protected virtual void OnPopulated(PopulatedEventArgs e)
        {
#if SILVERLIGHT
            PopulatedEventHandler handler = Populated;
            if (handler != null)
            {
                handler(this, e);
            }
#else
            RaiseEvent(e);
#endif
        }
コード例 #3
0
ファイル: AutoCompleteBox.cs プロジェクト: royosherove/cthru
        /// <summary>
        /// Notifies AutoCompleteBox that ItemsSource has been populated and 
        /// suggestions can now be computed using that data.
        /// </summary>
        /// <remarks>
        /// Allows a developer to continue the population event after setting 
        /// the Cancel property to True. This allows for custom, 
        /// developer-driven AutoCompleteBox scenarios.
        /// </remarks>
        public void PopulateComplete()
        {
            // Apply the search filter
            RefreshView();

            // Fire the Populated event containing the read-only view data.
            PopulatedEventArgs populated = new PopulatedEventArgs(new ReadOnlyCollection<object>(View));
            OnPopulated(populated);

            if (SelectionAdapter != null && SelectionAdapter.ItemsSource != View)
            {
                SelectionAdapter.ItemsSource = View;
            }

            IsDropDownOpen = UserCalledPopulate && (View.Count > 0);
            if (IsDropDownOpen)
            {
                ArrangePopup();
            }

            UpdateTextCompletion(UserCalledPopulate);
        }
コード例 #4
0
 /// <summary>
 /// Raises the
 /// <see cref="E:System.Windows.Controls.AutoCompleteBox.Populated" />
 /// event.
 /// </summary>
 /// <param name="e">A
 /// <see cref="T:System.Windows.Controls.PopulatedEventArgs" />
 /// that contains the event data.</param>
 protected virtual void OnPopulated(PopulatedEventArgs e)
 {
     PopulatedEventHandler handler = Populated;
     if (handler != null)
     {
         handler(this, e);
     }
 }
コード例 #5
0
ファイル: AutoCompleteComboBox.cs プロジェクト: SaintLoong/PD
 //highlighting logic
 protected override void OnPopulated(PopulatedEventArgs e)
 {
     base.OnPopulated(e);
     ListBox listBox = GetTemplateChild("Selector") as ListBox;
     if (listBox != null)
     {
         //highlight the selected item, if any
         if (this.ItemsSource!=null && this.SelectedItem != null)
         {
             listBox.SelectedItem = this.SelectedItem;
             listBox.Dispatcher.BeginInvoke(delegate
             {
                 listBox.UpdateLayout();
                 listBox.ScrollIntoView(listBox.SelectedItem);
                 //listBox.UpdateLayout();
             });
         }
     }
 }