AutoCompleteBox loses highlighting when the item collection changes while the AutoCompleteBox is active and the popup is open.

3 posts, 0 answers
  1. Pooja
    Pooja avatar
    10 posts
    Member since:
    Oct 2014

    Posted 14 Oct 2014 Link to this post

    AutoCompleteBox loses its highlighting when the itemsource collection changes. To reproduce this issue type in the AutoCompleteBox and while it’s active and the popup is open, trigger a collection change event. The highlighting will automatically disappear, now if the collection changes again the highlighting reappears. This keeps toggling back and forth.

    Attached is the screenshot.

    Below are the code snippets.

    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using Telerik.Windows.Controls;
     
    namespace HighlightMatchingItemsText
    {
        public class Country
        {
            public string Name { get; set; }
            public string Capital { get; set; }
        }
     
        public class ViewModel : ViewModelBase
        {
            private ObservableCollection<Country> countries;
     
            public ViewModel()
            {
                this.Countries = new ObservableCollection<Country>()
                {
                    new Country() { Name = "Australia", Capital = "Canberra" },
                    new Country() { Name = "Bulgaria", Capital = "Sofia" },
                    new Country() { Name = "Canada", Capital = "Ottawa" },
                    new Country() { Name = "Denmark", Capital = "Copenhagen" },
                    new Country() { Name = "France", Capital = "Paris" },
                    new Country() { Name = "Germany", Capital = "Berlin" },
                    new Country() { Name = "India", Capital = "New Delhi" },
                    new Country() { Name = "Italy", Capital = "Rome" },
                    new Country() { Name = "Norway", Capital = "Oslo" },
                    new Country() { Name = "Russia", Capital = "Moscow" },
                    new Country() { Name = "Spain", Capital = "Madrid" },
                    new Country() { Name = "United Kingdom", Capital = "London" },
                    new Country() { Name = "United States", Capital = "Washington, D.C." },
                };
     
                var o = System.Reactive.Linq.Observable.Start(() =>
                {
                    //starts on a background thread.
                    while (true)
                    {
                        Thread.Sleep(6000);
                        this.Countries = new ObservableCollection<Country>()
                        {
                            new Country() { Name = "Australia", Capital = "Canberra" },
                            new Country() { Name = "Bulgaria", Capital = "Sofia" },
                            new Country() { Name = "Canada", Capital = "Ottawa" },
                            new Country() { Name = "Denmark", Capital = "Copenhagen" },
                        };
                        Console.WriteLine("Collection Changed");
                    }
                });
     
            }
     
             public ObservableCollection<Country> Countries
            {
                get { return this.countries; }
                set
                {
                    if (this.countries != value)
                    {
                        this.countries = value;
                        this.OnPropertyChanged(() => this.Countries);
                    }
                }
            }
        }
    }

    <UserControl x:Class="HighlightMatchingItemsText.Example"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                 xmlns:local="clr-namespace:HighlightMatchingItemsText"
                 mc:Ignorable="d"
                 d:DesignHeight="300" d:DesignWidth="300" Width="300">
        <UserControl.DataContext>
            <local:ViewModel />
        </UserControl.DataContext>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <TextBlock Text="Type A in the autocomplete box, Australia gets highlighted. Keep the drop down open and wait for 6 seconds, the collection changes and the highlighting dissappears.
                       Wait for another 6 seconds, the collection changes and the highlighting reappaers. This keeps toggling. "
                       TextWrapping="Wrap"
                       FontWeight="Bold"
                       Margin="20"/>
            <telerik:RadAutoCompleteBox x:Name="AutoComplete"
                                        Grid.Row="1"
                                        Margin="20"
                                        ItemsSource="{Binding Countries}"
                                        TextSearchPath="Name"
                                        TextSearchMode="Contains"
                                        AutoCompleteMode="Suggest"
                                        >
            </telerik:RadAutoCompleteBox>       
        </Grid>
    </UserControl>


  2. Pooja
    Pooja avatar
    10 posts
    Member since:
    Oct 2014

    Posted 14 Oct 2014 Link to this post

    Reposted in the 'Telerik Forums / UI for WPF Forum / AutoCompleteBox /'   forum.

    http://www.telerik.com/forums/autocompletebox-loses-highlighting-when-the-item-collection-changes-while-the-autocompletebox-is-active-and-the-popup-is-open-66b627941d96#SjY82kSRz0ap4L3Y_AkZYQ
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 17 Oct 2014 Link to this post

    Hello Pooja,

    Could we continue the discussion in the other thread (with ID: 869129) which you have started.

    Regards,
    Vladi
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top