This is a migrated thread and some comments may be shown as answers.

Why RadListBox shows nothing during data filtering?

1 Answer 131 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Md.Hasanuzzaman
Top achievements
Rank 1
Md.Hasanuzzaman asked on 14 Sep 2012, 11:23 AM
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 :
    <Window.Resources>
        <local:MyList x:Key="MyData"/>
        <CollectionViewSource x:Key="MyCollection" Source="{Binding ClassTwos, Source={StaticResource MyData}}"/>
    </Window.Resources>

    <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()
        {
            InitializeComponent();


            var collectionView = (this.ListTwo.ItemsSource as ICollectionView);
            if (collectionView != null)
            {
                collectionView.Filter = p => ((TestClassTwo)p).Name == "s";
            }
        }

1 Answer, 1 is accepted

Sort by
0
Accepted
George
Telerik team
answered on 14 Sep 2012, 02:07 PM
Hi,

 
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,
George
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.

Tags
ListBox
Asked by
Md.Hasanuzzaman
Top achievements
Rank 1
Answers by
George
Telerik team
Share this question
or