---
title: "WPF: Binding List to ListBox in wpf?"  
description: "WPF: Binding List to ListBox in wpf?"  
author: "Dag Hammarskjold"  
published: 2013-08-10  
updated: 2013-08-10  
canonical: https://www.mindstick.com/forum/1369/wpf-binding-list-to-listbox-in-wpf  
category: "wpf"  
tags: ["wpf"]  
reading_time: 2 minutes  

---

# WPF: Binding List to ListBox in wpf?

\

I have a class:

public class A : INotifyPropertyChanged

{

public List<B> bList { get; set; }

[public void](https://www.mindstick.com/interview/2715/can-we-write-static-public-void-instead-of-public-static-void) AddB(B b)

{

bList.Add(b);

NotifyPropertyChanged("bList");

}

public event PropertyChangedEventHandler PropertyChanged;

[private](https://www.mindstick.com/blog/11097/java-access-modifiers-the-public-and-the-private-modifiers) void NotifyPropertyChanged([string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) info)

{

if (PropertyChanged != null)

{

PropertyChanged(this, new PropertyChangedEventArgs(info));

}

}

}

And a [binding](https://www.mindstick.com/blog/146/dynamic-binding-in-c-sharp) (DataContext of [UserControl](https://www.mindstick.com/forum/12739/set-the-enabled-property-of-a-usercontrol-from-codebehind) is an [instance](https://www.mindstick.com/forum/155658/testing-connection-to-cloud-sql-instance-with-a-mysql-client-from-vm-instance) of A):

<[ListBox](https://www.mindstick.com/articles/626/listbox-events-in-c-dot-net) ItemsSource="{Binding Path=bList}" />

[Elements](https://www.mindstick.com/forum/1440/wpf-button-with-multiple-text-elements) are shown, the ListBox is not updated after new object is added to List

After changing list to [ObservableCollection](https://www.mindstick.com/forum/1367/difference-between-observablecollection-and-bindinglist-in-wpf) and removing the NotifyPropertyChanged [handler](https://www.mindstick.com/forum/33532/handler-pagehandlerfactory-integrated-has-a-bad-module-managedpipelinehandler-in-its-module-list) everything works.

Why the list is not working?

## Replies

### Reply by Pravesh Singh

I think that the problem is that, although you are notifying the binding framework that the property has changed, the actual value of the property remains the same. That is to say that although the listbox may reevaluate the value of its ItemsSource binding, it will find that it is still the same object instance as previously. For example, imagine that the listbox reacts by to the property changed event somehow similar to the below.

```
private void OnItemsSourceBindingChanged(){    var newValue = this.EvaluateItemsSourceBinding();    if (newValue != this.ItemsSource) //it will be equal, as its still the same list    {        this.AddNewItems();    }}
```

In your example, this would mean that it would not reevaluate the items.


---

Original Source: https://www.mindstick.com/forum/1369/wpf-binding-list-to-listbox-in-wpf

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
