This question is locked. New answers and comments are not allowed.
Hello,
I have some trouble with the VirtualQueryableCollectionView and FilterDescriptors. If I add a FilterDescriptor to the VirtualQueryableCollectionView the ItemsLoading Event is never called. If I don't add the FilterDescriptor the ItemsLoading event is called.
I have searched around the web, but I haven't found a solution or some information about why.
In xaml code I have defined a RadComboBox
The Codebehind of this xaml looks like this:
I am little bit confused, why the ItemsLoading event is not fired, if I had added a FilterDescriptor. The reason is that I don't want to load all entries at one time, it should have a behavour like loading on demand. First 10 entries, if the user scrolls down in the combobox the next 10, and so on, filtered by the text the user has entered in the input area of the combobox.
Has anyone an idea, what I have to change to get this working?
I have some trouble with the VirtualQueryableCollectionView and FilterDescriptors. If I add a FilterDescriptor to the VirtualQueryableCollectionView the ItemsLoading Event is never called. If I don't add the FilterDescriptor the ItemsLoading event is called.
I have searched around the web, but I haven't found a solution or some information about why.
In xaml code I have defined a RadComboBox
<UserControl.Resources> <ResourceDictionary> <DataTemplate x:Key="cbPersonItemTemplate"> <StackPanel> <TextBlock Text="{Binding Name}" /> </StackPanel> </DataTemplate> </ResourceDictionary> </UserControl.Resources> <Grid x:Name="LayoutRoot" Background="White"> <telerik:RadComboBox x:Name="cbPerson" Text="{Binding Path=Text, Mode=TwoWay}" ItemsSource="{Binding Path=CollectionView}" ItemTemplate="{StaticResource cbPersonItemTemplate}" IsEditable="True" Width="200" Height="30" VerticalAlignment="Top" HorizontalAlignment="Left"> <telerik:RadComboBox.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel /> </ItemsPanelTemplate> </telerik:RadComboBox.ItemsPanel> </telerik:RadComboBox> </Grid>The Codebehind of this xaml looks like this:
public partial class PersonSelector : UserControl, INotifyPropertyChanged{ public PersonSelector() { InitializeComponent(); int personCount = 10000; //10000 Personen erzeugen Person.CreatePersons(personCount); collectionView = new VirtualQueryableCollectionView<Person>() { LoadSize = 10, VirtualItemCount = personCount }; collectionView.FilterDescriptors.Add(new FilterDescriptor("SearchKey", FilterOperator.StartsWith, "")); collectionView.ItemsLoading += collectionView_ItemsLoading; cbPerson.DataContext = this; } private void collectionView_ItemsLoading(object sender, VirtualQueryableCollectionViewItemsLoadingEventArgs e) { var searchKey = String.Empty; if (CollectionView.FilterDescriptors.Count > 0) searchKey = (CollectionView.FilterDescriptors[0] as FilterDescriptor).Value.ToString(); else searchKey = Text; var pList = Person.GetPersons(searchKey, e.StartIndex, e.ItemCount); CollectionView.Load(e.StartIndex, pList); } private VirtualQueryableCollectionView collectionView; public virtual VirtualQueryableCollectionView CollectionView { get { return collectionView; } set { collectionView = value; DoPropertyChanged("CollectionView"); } } private string text; public string Text { get { return text; } set { if (text != value) { text = value; if (CollectionView.FilterDescriptors.Count > 0) (CollectionView.FilterDescriptors[0] as FilterDescriptor).Value = text; DoPropertyChanged("Text"); } } } #region INotifyPropertyChanged Members public virtual event PropertyChangedEventHandler PropertyChanged; public virtual void DoPropertyChanged(string propertyName) { if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } #endregion INotifyPropertyChanged Members}I am little bit confused, why the ItemsLoading event is not fired, if I had added a FilterDescriptor. The reason is that I don't want to load all entries at one time, it should have a behavour like loading on demand. First 10 entries, if the user scrolls down in the combobox the next 10, and so on, filtered by the text the user has entered in the input area of the combobox.
Has anyone an idea, what I have to change to get this working?