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

  • SEARCH
  • Home
  • 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 7009299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:50:40+00:00 2026-05-27T21:50:40+00:00

I am implementing a simple MVVM WPF application with simple databrowsing commands. There is

  • 0

I am implementing a simple MVVM WPF application with simple databrowsing commands.

There is a xaml-window with a listbox

    <ListBox x:Name="listBoxPersons" ItemsSource="{Binding Path=Persons}" SelectedIndex="{Binding Path=SelectedPerson, Mode=OneWayToSource}"  Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" Margin="0,10,10,5" IsSynchronizedWithCurrentItem="True">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Path=Name, UpdateSourceTrigger=PropertyChanged}" />
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

Besides there is a textbox to insert the where-clause

    <TextBox Grid.Column="2" Grid.Row="6" Margin="0,5,10,5" Name="textBoxWhereClause" />

Persons is a ObservableCollection. I implemented simple Add / Delete / Change Commands for the persons. This works.

Question: what do i have to do, if the user performs a new query resulting in a completely new collection? How can a bind the new collection dynamically to the listbox?

I am a WPF beginner and helpless.

Any help is very appreciated!

  • 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-05-27T21:50:41+00:00Added an answer on May 27, 2026 at 9:50 pm

    How can I bind the new collection dynamically to the listbox?

    You don’t need to reset the binding. Binding is already there you only need to update the binding source.

    Simply you have to replace the Persons collection with newly retrieved results

    You must have something similar to this in your View Model

    private ObservableCollection<Person> _Person ;
    public ObservableCollection<Person> Person
    {
        get
        {  
            return _Person;
        }
        set
        {
            _Person = value;
            OnPrpertyChanged("Person");
        }
    }
    

    you can do Person = YourNewCollection; //newly retrieved results

    but there are about 50,000 persons in the table. This could result in performance difficulties

    There are two things you can do

    1) only retrieve limited number of records at a time and provide user next back buttons. Kind of paging.

    2) use virtualization option in ListBox so that UI can be responsive and efficient. It makes sure only those objects are loaded from Person collection into listbox which are can be displayed at a certain point of time

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whilst implementing my first MVVM application in WPF, I've been wondering about the pros
I'm implementing a simple update mechanism for an application I'm writing the last part
Ok...... I'm implementing a simple OpenGL ES application on the iPhone and I recently
I am implementing a quite simple state-machine order processing application. It is a e-commerce
I'm working on implementing a reasonably simple XML serializer/deserializer (log file parser) application in
I am implementing a simple license-file system, and would like to know if there
Hi i am implementing a simple threaded GUI application in QT 4.6.2. I am
Is there a library for implementing Simple Service Discovery Protocol(SSDP) via UPnP in Python?
I tried implementing a simple web service into an asp.net application using the tutorial
I am implementing a simple plugin architecture in an application. The plugin requirements are

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.