Export (0) Print
Expand All

AutoCompleteBox.MinimumPopulateDelay Property

Silverlight

Gets or sets the minimum delay, in milliseconds, after text is typed in the text box before the AutoCompleteBox control populates the list of possible matches in the drop-down.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls.Input (in System.Windows.Controls.Input.dll)

public int MinimumPopulateDelay { get; set; }
<sdk:AutoCompleteBox MinimumPopulateDelay="int"/>

Property Value

Type: System.Int32
The minimum delay, in milliseconds, after text is typed in the text box, but before the AutoCompleteBox populates the list of possible matches in the drop-down. The default is 0.

ExceptionCondition
ArgumentException

The set value is less than 0.

Population of the AutoCompleteBox does not occur until the conditions specified by the MinimumPrefixLength and the MinimumPopulateDelay property values are met.

You can use the MinimumPopulateDelay property to delay the appearance of the drop-down when manually populating the selector control.

The following code example demonstrates how to use the MinimumPopulateDelay and MinimumPrefixLength properties together with handling the Populating event to populate the AutoCompleteBox manually. This code example sets the PopulatingEventArgs.Cancel property to true to stop auto-population and then calls PopulateComplete when the manual population operation is complete. This code example requires a reference to the System.Windows.Controls.Input assembly.

Run this sample


    // Handle the Populating event, but cancel it. Make the call to the web service.
    private void AutoCompleteBox_Populating(object sender, PopulatingEventArgs e)
    {
        e.Cancel = true;
        CallToWebService();
    }

    // Call the topic service at the live search site.
    WebClient wc;
    private void CallToWebService()
    {
        wc = new WebClient();
        wc.DownloadStringAsync(new Uri
            ("http://api.search.live.net/qson.aspx?query=" + myACB.SearchText +
            "&sources=news"));
        wc.DownloadStringCompleted +=
            new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
    }

    void wc_DownloadStringCompleted(object sender,
        DownloadStringCompletedEventArgs e)
    {
        if (e.Error != null)
        {
            return;
        }

        List<string> data = new List<string>();
        try
        {
            JsonObject jso = ((JsonObject)JsonObject.Parse(e.Result))
                ["SearchSuggestion"] as JsonObject;
            string originalSearchString = jso["Query"];
            if (originalSearchString == myACB.SearchText)
            {
                foreach (JsonObject suggestion in (JsonArray)jso["Section"])
                {
                    data.Add(suggestion.Values.First());
                }

                // Diplay the AutoCompleteBox drop down with any suggestions
                myACB.ItemsSource = data;
                myACB.PopulateComplete();
            }
        }
        catch { }
    }
}



   <StackPanel x:Name="LayoutRoot" Background="White" Orientation="Horizontal">
    <TextBlock Text="News Topic:" HorizontalAlignment="Left"  VerticalAlignment="Center"/>
    <sdk:AutoCompleteBox VerticalAlignment="Center" HorizontalAlignment="Right" Height="30" 
        Width="100" MinimumPopulateDelay="200" MinimumPrefixLength="3" x:Name="myACB" Populating="AutoCompleteBox_Populating" />
</StackPanel>


Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft