Visual Studio Developer Center > Visual Studio Forums > Visual Studio WPF Designer > Collection Object Binding in WPF for a ListBox
Ask a questionAsk a question
 

QuestionCollection Object Binding in WPF for a ListBox

  • Tuesday, November 03, 2009 9:10 PMUncleMeat Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    This began as an easy query which I thought would yield a solution. After 3 days of browsing this site and the web in general I've encountered at least 50 different ways to bind a collection object to a listbox in WPF and none of them are the same. How is this possible? There are so many pieces to some of these so-called solutions that I'd actually save time by coding for the actual events to update the listbox and/or the object.

    If there is someone out there who can understand my frustration in learning this and would be able to tell me clearly and concisely what components are needed, I would greatly appreciate it.

All Replies

  • Friday, November 06, 2009 2:25 AMMark Wilson-ThomasMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi @UncleMeat

    There are many ways to plumb the underlying objects to your listbox, as you say.

    The good news is there's a quick and easy way to make this happen which is supported by the new Visual Studio 2010 Beta 2 Data Sources Window; the tool does all the work for you and produces a nice clean binding via a CollectionViewSource object.

    See a demo at http://channel9.msdn.com/pdc2008/PC45/

    (in the demo I use a database but the wizard lets you pick a plain object to bind to as well).

    Download Visual Studio 2010 Beta 2 at
    http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx

    Mark


    Mark Wilson-Thomas - Program Team - WPF & SL Designer for Visual Studio - posts are provided 'as-is'