/// <summary>
 /// Raises the Populated event when the AutoCompleteBox has populated the 
 /// selection adapter with suggestions based on the text property.
 /// </summary>
 /// <param name="e">The populated event data.</param>
 protected virtual void OnPopulated(PopulatedEventArgs e)
 {
     PopulatedEventHandler handler = Populated;
     if (handler != null)
     {
         handler(this, e);
     }
 }
Exemple #2
0
        //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();
                    });
                }
            }
        }
Exemple #3
0
 /// <summary>
 /// Performs test actions for the OnPopulated method.
 /// </summary>
 /// <param name="e">Event arguments.</param>
 protected override void OnPopulated(PopulatedEventArgs e)
 {
     PopulatedActions.DoPreTest(e);
     base.OnPopulated(e);
     PopulatedActions.DoTest(e);
 }
        /// <summary>
        ///     Notifies the
        ///     <see cref="T:ModernUI.ExtendedToolkit.AutoCompleteBox" /> that the
        ///     <see cref="ModernUI.ExtendedToolkit.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);
        }
 /// <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
 }
Exemple #6
0
        /// <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);
        }
 /// <summary>
 /// Performs test actions for the OnPopulated method.
 /// </summary>
 /// <param name="e">Event arguments.</param>
 protected override void OnPopulated(PopulatedEventArgs e)
 {
     PopulatedActions.DoPreTest(e);
     base.OnPopulated(e);
     PopulatedActions.DoTest(e);
 }