Filter not work with custom data template

2 posts, 0 answers
  1. Aeroth
    Aeroth avatar
    17 posts
    Member since:
    Oct 2010

    Posted 21 Jan 2013 Link to this post

    Hi Telerik Support,

    I wrote a simple ComboBox with my custom data template but the filter functionality does not work properly. E.g., I added 5000 items to my ComboBox (from 1 to 5000) I can find the value of 3333 by scrolling down the ComboBox, but if I filter with 3333 some values are gone.
    Did anything go wrong? Thanks!
    Below is my code:

    public class MyComboBox : RadComboBox
            private MyComboBoxItemCollection _itemList;
            public MyComboBox()
                this._itemList = new MyComboBoxItemCollection();
                base.IsEditable = true;
                base.IsFilteringEnabled = true;
                base.StaysOpenOnEdit = true;
                base.TextSearchMode = Telerik.Windows.Controls.TextSearchMode.StartsWith;
                base.IsReadOnly = true;
                DataTemplate selData = (DataTemplate)XamlReader.Load(
                            <TextBlock Text=""{Binding Value}""/>                                           
                DataTemplate itemTmp = (DataTemplate)XamlReader.Load(
                        <StackPanel Orientation=""Horizontal"">
                            <TextBlock Text=""{Binding Value}""/>
                            <TextBlock Text="" ""/>
                            <TextBlock Text=""{Binding Description}"" Foreground=""Blue"" />
                ItemsPanelTemplate itemsPanelTmp = (ItemsPanelTemplate)XamlReader.Load(
                        <VirtualizingStackPanel />
                base.SelectionBoxTemplate = selData;
                base.ItemTemplate = itemTmp;
                base.ItemsPanel = itemsPanelTmp;
                base.SelectedValuePath = "Value";
                Telerik.Windows.Controls.TextSearch.SetTextPath(this, "Value");
            public void Add(string showText, object description, object value)
                MyComboBoxItem item = new MyComboBoxItem()
                    DataContext = value,
                    Value = showText,
                    Description = description == null ? string.Empty : description.ToString(),
                base.ItemsSource = _itemList;
            public void Add(object value, object description)
                this.Add(value.ToString(), description, value);
            public void Add(object value)
                this.Add(value, "");
        public class MyComboBoxItem
            public string Value { get; set; }
            public string Description { get; set; }
            public object DataContext { get; set; }
        public class MyComboBoxItemCollection : ObservableCollection<MyComboBoxItem>
            public MyComboBoxItemCollection()
                : base()

    Aeroth Lin
  2. Yana
    Yana avatar
    4604 posts

    Posted 24 Jan 2013 Link to this post

    Hi Aeroth,

    I noticed in your code that you're using VirtualizingStackPanel - note that virtualization and filtering features in RadComboBox cannot be used together. The reason for this is that RadComboBox is an ItemsControl. I would suggest to check our RadAutoCompleteBox control which supports such scenarios.

    All the best,
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top