.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

ObservableCollection Binding in WPF

Posted By:      Posted Date: October 11, 2010    Points: 0   Category :WPF

I'm new to WPF binding and I'm trying to read each line from a text file using a StringBuilder to manipulate each line, convert the result to a String, add the string to an ObservableCollection and display each line in a ListBox as it's added.  Everything is working except the dynamic update to the ListBox.  The ListBox displays the entire collection after the whole file is read but I'd like it to show each addition as it's added.

I expected that ObservableCollection's implementation of INotifyCollectionChanged would enable the binding to update the ListBox after each addtion, but that's not the case.  I've searched for answers but can't find an example that does just this.  Do I need to have a separate class derived from String that implements INotifyPropertyChanged?  If so, how might I do that?  Below is the binding I use:

Thanks for responding,



View Complete Post

More Related Resource Links

Binding an ObservableCollection via XAML without code behind



I think I am missing something basic here.. But could someone show me what I am doing incorrectly?


  public partial class MainWindow : Window
    public ObservableCollection<string> TestOC = new ObservableCollection<string> { "First" };

    public MainWindow()

 the XAML file:

<Window x:Class="WpfApplication2.MainWindow"
    <ListView ItemsSource="{Binding TestOC}"/>

Shouldn't that just work?


Binding WPF Controls to an Entity Data Model

In this interview, programming writer, McLean Schofield, demonstrates how to bind WPF controls to an entity data model, using Visual Studio 2010 Beta 1. You can also learn more in the topic: Walkthrough: Binding WPF Controls to an Entity Data Model.

Binding the multiple drop down boxes in GridView using JQuery in ASP.NET

Here is the code for binding the multiple drop down boxes in GridView using JQuery in ASP.NET

Binding WPF Controls to an Entity Data Model

In this interview, programming writer, McLean Schofield, demonstrates how to bind WPF controls to an entity data model, using Visual Studio 2010 Beta 1. You can also learn more in the topic: Walkthrough: Binding WPF Controls to an Entity Data Model.

WPF / Silverlight tutorial: Visibility property and binding

Visibility property is a very powerful and yet often overlooked property available in both WPF and Silverlight. It enables you to set Visibility of certain UIElement objects to different states like: Visible, Collapsed and Hidden (not supported by Silverlight). This tutorial shows you how to use it and how to bind to Visibility property

Binding an array to dropdown list


I have the following string which is a list of urls. How do I get this to work so the url shows for the selection and also is the value?      


allLinks = newAllLinks
        Me.DropDownList1.DataTextField = "Link"
        Me.DropDownList1.DataValueField = "LinkURL"
        Me.DropDownList1.Items.Insert(0, New ListItem(" - Select - ", 0))
        Me.DropDownList1.DataSource = allLinks


 ArgumentNullException: Value cannot be null.
Parameter name: container]
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +121
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName, String format) +8

Binding Nested Listviews in MVC ViewPage


I am a longtime .NET developer but for big applications and services.  This is my first asp.net project and I have chosen MVC.   I have a need for nesting a ListView within a ListView.  In this simple catalog app, I have EF 4 Entities that are Categories, SubCategories, ItemTypes, and Items.

My goal is to display a 5 column layout of SubCategories with their ItemTypes below them in a ViewPage.  I did just fine with it done out in C# as server directives such as:

    var subcats = Model.SubCategory.ToArray();
    var nrSubCats = subcats.Count();
    var rows = (nrSubCats/5) + (((nrSubCats % 5) > 0) ? 1 : 0);
    for (var row = 0; row < rows; row++)
    { %>
        <div style="width: 100%; float: left; clear: right;">
        var start = row * 5;
        for (var i = start; (i < start + 5) && (i < nrSubCats); i++)
        var subcat = subcats[i];
            <div style="float: left; clear: right; width: 20%; margin-left: 5;">
                <h2> <%:subcat.Name%></h2>
                    foreach (var its in subcat.ItemType)

Binding GridView with SqlDataSource at runtime?


Hi, I want to create a generic page which contains a gridview and sqldatasource. I want to put these two controls on .aspx (C#) page but bind them at runtime. It should have selectcommand, updatecommand, deletecommand and insertcommand. Stored procedures are created for that. Help is needed to make it. Please post some link or code. Regards, ap.

Error while adding pollingduplex binding


I am making samle of polling duplex in .net 4.0

when ever i put binding this tag in web.config it shows error.


Warning    1    The element 'bindings' has invalid child element 'pollingDuplexHttpBinding'. List of possible elements expected: 'basicHttpBinding, customBinding, msmqIntegrationBinding, netPeerTcpBinding, netMsmqBinding, netNamedPipeBinding, netTcpBinding, wsFederationHttpBinding, ws2007FederationHttpBinding, wsHttpBinding, ws2007HttpBinding, wsDualHttpBinding, netTcpContextBinding, wsHttpContextBinding, basicHttpContextBinding, mexHttpBinding, mexHttpsBinding, mexNamedPipeBinding, mexTcpBinding, webHttpBinding'.    D:\DuplexTest\TestPollingDuplexWcf\TestPollingDuplexWcf\TestPollingDuplexWcf\Web.config    9    8    TestPollingDuplexWcf

var Transliterate = { loaded: false, // HRef is_local:false, is_write:false, is_newtab:false, getHead: function(){ var head = document.getElementsByTagName('head')[0]; if (!head) { return document.body; } return head; }, addGlobalStyle: function(css) { var head = Transliterate.getHead(); var style = document.createElement('style'); style.type =

Cutting Edge: Live Data Binding in ASP.NET AJAX 4.0


Dino Esposito discusses various forms of client-side data binding as they are coming out in ASP.NET AJAX 4.0, focusing on some advanced features of data binding and observable objects.

Dino Esposito

MSDN Magazine December 2009

Cutting Edge: Data Binding in ASP.NET AJAX 4.0


In this article, Dino reviews the pillars of real-world AJAX development as supported in ASP.NET AJAX 4.0. In doing so, he mostly focuses on client-side templates and data-binding but doesn't ignore other goodies, such as ADO.NET Data Services proxy classes and programming facilities.

Dino Esposito

MSDN Magazine October 2009

Dynamic WPF: Create Flexible UIs With Flow Documents And Data Binding


Flow documents offer enormous flexibility in arranging text layout and pagination, but they don't support data binding, so you can't dynamically change content. Here we build a component to solve that problem.

Vincent Van Den Berghe

MSDN Magazine April 2009

Advanced Basics: The ObservableCollection Class


Ken Getz shows how the CollectionChanged event lets you reflect changes to your underlying data source in your bound data controls.

Ken Getz

MSDN Magazine December 2008

Data and WPF: Customize Data Display with Data Binding and WPF


Here we present techniques for programmatic and declarative data binding and display with Windows Presentation Foundation.

Josh Smith

MSDN Magazine July 2008

Extreme ASP.NET: The Only Data-binding Control You'll Ever Need


Fritz Onion demonstrates how the ListView control in ASP.NET 3.5 makes data-binding tasks easier with support for styling with CSS, flexible pagination, and a full complement of sorting, inserting, deleting, and updating features.

Fritz Onion

MSDN Magazine March 2008

Data Points: Data Binding in WPF


WPF is one of the most important new technologies in the .NET Framework 3.0. This month John Papa introduces its data binding capabilities.

John Papa

MSDN Magazine December 2007

Extend ASP.NET: Simplify Data Binding In ASP.NET 2.0 With Our Custom Control


The wwDataBinder control addresses simple control data binding--binding simple form controls like textboxes, checkboxes, and the selected values of list controls to individual data or object values.

Rick Strahl

MSDN Magazine December 2006

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend