Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8203969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:44:36+00:00 2026-06-07T07:44:36+00:00

I have simple test (WPF – MVVM) client (for WCF oData service) app: ViewModel

  • 0

I have simple test (WPF – MVVM) client (for WCF oData service) app:

ViewModel

public class MainViewModel : ViewModelBase
{
    private MyEntities context;

    public ICollectionView Collection { get; private set; }

    private string searchString = "";
    public string SearchString
    {
        get { return searchString; }
        set
        {
            searchString = value;
            Collection.Refresh();
        }
    }

    public MainViewModel()
    {
        context = new MyEntities(new Uri("http://localhost:3780/Live.svc"));

        Collection = new CollectionView(context.Clients);
        //Collection = new CollectionView(context.Clients.ToArray());

        Collection.Filter = (o) => (o as Client).FullName.ToString().StartsWith(SearchString);
    }
}

and View

<ListBox ItemsSource="{Binding Collection}">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding FullName}" />
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

<TextBox Grid.Row="1" Text="{Binding SearchString, UpdateSourceTrigger=PropertyChanged}" />

I have two questions:

  1. Why the movement of the ListBox slider slows down S_O___M_U_C_H (I
    have only 40 clients in the collection)?
  2. Why, if I change this

    Collection = new CollectionView(context.Clients);
    

    to this

    Collection = new CollectionView(context.Clients.ToArray());
    

    so to break “connection” with the context through IEnumerable shell
    (it helps with UI performance problems) – stops working filtering! I
    do not understand why the disconnection of the collection from data
    context damage the filtering…

So, my final question is – is it possible to avoid GUI performance problems and at the same time implement filtering? And if so, how?

Any suggestions are welcome!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:44:38+00:00Added an answer on June 7, 2026 at 7:44 am

    Ok, guys, I solved my problem. I should just pay attention to the message In the VS Output window:

    Using CollectionView directly is not fully supported. The basic features work, although with some inefficiencies, but advanced features may encounter known bugs. Consider using a derived class to avoid these problems.

    The solution was simple:

    I changed this

    Collection = new CollectionView(context.Clients);
    

    to this

    Collection = new ListCollectionView(context.Clients.ToList());
    

    and then there are no GUI performance problems and filtering works as expected!

    The result code was:

    ViewModel:

    public class MainViewModel : ViewModelBase
    {
        private MyEntities context;
    
        public ICollectionView Collection { get; private set; }
    
        private string searchString = "";
        public string SearchString
        {
            get { return searchString; }
            set
            {
                searchString = value;
                Collection.Refresh();
            }
        }
    
        public MainViewModel()
        {
            context = new MyEntities(new Uri("http://localhost:3780/Live.svc"));
    
            Collection = new ListCollectionView(context.Clients.ToList());
    
            Collection.Filter = (o) => (o as Client).FullName.ToString().StartsWith(SearchString);
        }
    }
    

    and View:

    <Grid x:Name="LayoutRoot"> 
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        
        <ListBox ItemsSource="{Binding Collection}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding FullName}" />
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    
        <TextBox Grid.Row="1" Text="{Binding SearchString, UpdateSourceTrigger=PropertyChanged}" />  
    </Grid>
    

    WCF Data Service:

    public static void InitializeService(DataServiceConfiguration config)
    {
        config.SetEntitySetAccessRule("*", EntitySetRights.All);
        config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
        config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
    
        config.UseVerboseErrors = true; 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple test project just to test the IncludeExceptionDetailInFaults behavior. public class
I have a simple test purpose WCF service. I'm trying to host it under
Im having some problems with binding in wpf/xaml. Have this simple file: <Window x:Class=test.Window1
I have simple controller: public class TestController : Controller { public ActionResult Test(string r)
Deploying on JBoss AS 7.1.0.Final. I have a very simple test app. It was
I have written a simple WPF application in which I wanted to test the
I have a simple wpf app which has a button that increments a value
I have a simple resftul wcf service. The .svc file looks like this <%@
I have created a simple WPF test program, based on what Visual Studio gives
I have a simple test case failing in Django: Model (app/models.py): from django.db import

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.