Condividi tramite


Drag-Drop Data Binding For WPF (by Milind Lele)

One of the improvements in VS2010 (CTP available for download here) is drag and drop data binding for WPF applications. Drag-drop data binding has been available for WinForms since Visual Studio 2005. So those of you that are familiar with that will find the WPF experience quite similar and readily usable. This post briefly outlines the improvements in the VS2010 CTP.

At one end of the binding is, of course the control that you are binding, the target. At the other end is data source. In VS2010 you can add either a DataSet or an Entity Data Model to your WPF application and bind the tables or entities to WPF controls by simply dragging the table or the entity and dropping onto the form.

Entity Data Model designer support was added to Visual Studio 2008 SP1. To add an entity data model to your application click Add New Item on the project menu, then select ADO.NET Entity Data Model.

AddItem

The EDM wizard is displayed allowing you to specify a connection to your database and select tables that you wish to add to your model.

 AddItem

In VS2010, once an EDM is added to a project it will show up in the data sources window.

DSWin

This acts as the drag source for your binding. From here there are different ways you can go about establishing bindings to your UI. One is to create the UI control, say a ListBox, from the toolbox, then drag-drop an entity from the data sources window to the listbox. Alternately you could generate the control from the data sources window itself. Select an entity and drop it onto the form. The data sources window allows you to select what control you wish to generate. That control gets generated and bound to the entity.

Comments

  • Anonymous
    November 07, 2008
    PingBack from http://mstechnews.info/2008/11/drag-drop-data-binding-for-wpf-by-milind-lele/

  • Anonymous
    November 19, 2008
    One of the improvements in VS2010 (CTP available for download here ) is drag and drop data binding for

  • Anonymous
    November 19, 2008
    One of the improvements in VS2010 (CTP available for download here ) is drag and drop data binding for

  • Anonymous
    November 25, 2008
    Today I was looking at comments on one of my WPF videos on how to create a Master-Detail form in WPF

  • Anonymous
    December 07, 2008
    If you aren't playing with the WPF 4.0 Visual Studio 2010 CTP already you should be.. There are some significant features and improvements that are worth a look and as far as time goes, not to far away in the distant future. One of the most exciting features

  • Anonymous
    April 16, 2009
    Parecia que as promessas iniciais com o lançamento do WPF no .NET Framework 3.0, chamado de Avalon durante

  • Anonymous
    May 15, 2009
    Today I posted a new interview on Channel 9 on WPF Improvements in Visual Studio 2010 for Building Business

  • Anonymous
    May 20, 2009
    Visual Studio 2010 Beta is released. Late last year we had released a Community Technology Preview (CTP)

  • Anonymous
    May 20, 2009
    This Monday, we released Beta1 of Visual Studio 2010 and .NET FX 4 to MSDN subscribers . Today it is