Why RadListBox shows nothing during data filtering?

2 posts, 1 answers
  1. Md.Hasanuzzaman
    Md.Hasanuzzaman avatar
    31 posts
    Member since:
    Apr 2011

    Posted 14 Sep 2012 Link to this post

    I am using ICollectionView for filters my data list. But when i try to filtering data then RadListBox shows nothing. Here is my Code which i try for this.

     XAML :
            <local:MyList x:Key="MyData"/>
            <CollectionViewSource x:Key="MyCollection" Source="{Binding ClassTwos, Source={StaticResource MyData}}"/>

        <telerik:RadListBox x:Name="ListTwo" ItemsSource="{Binding Source={StaticResource MyCollection}}" Margin="184,78,0,0"  Width="94" Height="175" DisplayMemberPath="Name"/>

    C# :
        public class MyList
            public ObservableCollection<TestClassTwo> ClassTwos { get; set; }
            public MyList()
                ClassTwos = new ObservableCollection<TestClassTwo>
                                                       new TestClassTwo{Name = "Sound"},
                                                       new TestClassTwo{Name = "Samsung"},
                                                       new TestClassTwo{Name = "yahoo"}


        public MainWindow()

                var collectionView = (this.ListTwo.ItemsSource as ICollectionView);
                if (collectionView != null)
                    collectionView.Filter = p => ((TestClassTwo)p).Name == "s";
  2. Answer
    George avatar
    1332 posts

    Posted 14 Sep 2012 Link to this post


    The RadListBox controls doesn't display the items because the filter condition returns zero items. If you change the filter with this one: ((TestClassTwo)p).Name.Contains("s"); the first two items will be displayed.

    Hope this helps.

    Kind regards,
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  3. DevCraft banner
Back to Top