WPF DataGrid and the WPFToolKit have released!

Finally, the v1 WPF DataGrid is out!  This is an out-of-band release that will be hosted on the WPF CodePlex site and integrated into the WPF Framework in vNext.  You can download the bits as well as the source code here.  You also may be pleased to hear that included with the WPFToolKit are other controls and features such as DatePicker, Calendar, and VSM!  For any questions/feedback/issues you may have you can post them on the WPF CodePlex discussion list.  Also, be sure to check our Tips & Tricks section on the CodePlex site for more resources and help.

So what’s new in the v1 WPF DataGrid?  Here are some of the features that were not in the CTP:

·         Row Validation

·         Row Details

·         Row Resizing

·         Hidden Columns

·         Column virtualization

·         Read-only columns and cells

·         Make-over of DataGridComboBoxColumn

·         Design experience for the DataGrid in Cider and Blend

·         UIAutomation support

·         Star column width redesign

·         Lots of bug fixes

There is a walkthrough of the feature set on windowsclient.net here and a hands-on lab that you can do here. I have updated the CTP Sample to include the new features.  You can bind to all of the DataGrid and DataGridColumn properties in real-time and I also included samples for DataTable and Linq to SQL scenarios.  You can download the sample here. 


I also plan to update all my previous posts and samples with the updated bits.  For better organization, I have made additional tags for DataGrid sample and DataGrid concepts.  If you have any feedback or particular samples that you would like to see please let me know.  Stay tuned for addtional material on the DataGrid, VSM, and more. 

Breaking changes and how to update CTP code to v1

1.  Update the xaml namespace from: xmlns:dg="clr-namespace:Microsoft.Windows.Controls;assembly=WpfToolkit" To: xmlns:dg=http://schemas.microsoft.com/wpf/2008/toolkit

2.  Update the 'DataFieldBinding' property to 'Binding'

3.  Update DataGridComboBoxColumn.DataFieldBinding to DataGridComboBoxColumn.SelectedItemBinding

4.  Include this namespace in code behind, using Microsoft.Windows.Controls.Primitives;


Comments (29)
  1. UPDATE: the WPF DataGrid v1 has just released. For more information, see this post . The information

  2. Bong says:

    Hi Vincent,

    Just replace the CTP Toolkit to v1 in my project and stumbled upon some problems. The CommittingEdit and CancelingEdit events seems to be gone. Were they removed? Or replaced by some other event?

  3. Bong,

    Those events have been replaced with CellEditEnding and RowEndEnding.  The args in the event handler will tell you if it is a commit or cancel action.

  4. Ruler says:

    Hi Vincent,

    I have a combobox in the datagrid for each row. Depending on the selection of the combobox, i would like to bind the row with different control.

    Do you know how i can do that ?

  5. Ruler,

    Could you explain a little more on how you want to bind a row to a different control.  Are you not using an ItemsSource then?  Generally rows are bound to data and not other controls.

  6. Ruler says:

    Actually, it’s simple.

    ON each column, i have a combobox and i would like to bind a textbox with different data in it.


    On each row, i have a combobox with selection of different GPS positions. Then on the next column,

    I would like to bind the textbox with the options selected.

  7. Ruler,

    Binding a row to a different control is not really what you are asking then.  A row is bound to the data source item.  Each cell is then bound to a property on the data item.  For your scenario, you can binding a property for the comboboxcolumn and the textcolumn to the same property as the comboboxcolumn will end up changing the property on the data source item and the textcolumn is just consuming the same property.  

  8. Sreeraj says:

    Hi Vincent,

         I’m looking for the row validation in datagrid v1. I went through your application and i saw that the row validation is binded with the ValidationHelper like this


                   <local:CustomerValidationRule ValidationStep="UpdatedValue" />


    . In the ValidationHelper I saw 4 classes inherited from ValidationRule and they contains overrided validate method in which validations is checked.

    What i didn’t understand is that how these validations are binded with corresponding cells in the row. And also I would like to know how the row tooltip is assigned with the error message.

    Thanking you with anticipation,


  9. Sreeraj,

    I wrote two posts on BindingGroups that may be able to help.  Here is the intro post, http://blogs.msdn.com/vinsibal/archive/2008/08/11/wpf-3-5-sp1-feature-bindinggroups-with-item-level-validation.aspx, and here is a post about the validation feedback, http://blogs.msdn.com/vinsibal/archive/2008/09/08/wpf-bindinggroup-and-validation-feedback.aspx.  If you have more questions after that just let me know.

  10. blindmeis says:


    I bind the grid to a DataTable. when there more then 20000 rows, grouping becomes veryyyy slow.

    any ideas how to make it faster?

  11. blindmeis,

    Grouping does not have virtualization built in and therefore is really slow.  You can add virtualization yourself.  Here is a post that points to that, http://blogs.msdn.com/vinsibal/archive/2008/06/12/grouping-and-virtualization.aspx.

  12. blindmeis says:

    Hi Vin,

    got he example running, but if i try this in my testapp.

    private ReadOnlyObservableCollection<object> BaseGroups




                   return base.Groups;



    is always null!

    if i look into the debug i can see its 40 after setting the groupdescription! i dont know why and when its set to null…

  13. blindmeis,

    It’s a little tough to tell the issue from just that.  Please email me a zipped repro.  

  14. The DataGrid walkthrough on windowsclient.net/wpf and the Tips &amp; Tricks section on codeplex talk

  15. sekhar says:

    Hi Vincent,

    We have a scenario in one of our applications. we have two dropdownlists in a row in the WPF datagrid. The requirement is that the 2nd dropdownlist should be populated depending on the value that is been selected in the 1st dropdownlist(PK FK relationship exists in the db).Can you please suggest the best way to go forward

  16. mb says:

    Does anyone have idea, how to get string from datagrid and put it into textbox? The command  DataGrid.Cells[x].Rows[y] doesn’t work and i couldn’t find any other fitting command. It’s surelly some obvios solution, but after few hours searching, I haven’t found anything.

  17. mb,

    You can go through your data source directly.  If you want to go through the DataGrid you can get the item by doing DataGrid.Items[x].  With the Item you have access to all the properties so you can just access it directly from there.  If you really want to use an index on the cell you can do something like this utility code on this thread, http://www.codeplex.com/wpf/Thread/View.aspx?ThreadId=34065, and call the GetCell() method.

  18. Bhuvan says:

    I was trying to put a button and an indented text box for displaying self-referential hierarchical data in the data grid.

    Trying to do as

    <dg:DataGridTemplateColumn Header="Id" >





                                               <ContentPresenter Content="{Binding Indent, Mode=OneTime}" Margin="2,0"/>

                                               <TextBlock Text="{Binding Path=conceptId}"/>





    I can see button but not any bound Items. If i bind these columns with regular TextColumn they show up fine.

    Any help will be appreciated.


  19. Bhuvan,

    So if you do something like this:

    <dg:DataGridTextColumn Binding="{Binding conceptId}" />

    it works?  Do you get any binding errors with your TemplateColumn above?

  20. Wayne says:

    I have a DataGridComboBoxColumn bound to a foreign key to another table. The combobox values are then populated from another datasource thus:

    <my:DataGridComboBoxColumn Header="Vetted Pos 1" ItemsSource="{Binding Source={StaticResource vetted}}" DisplayMemberPath="DESCRIPTION" SelectedValuePath="CODE" SelectedValueBinding="{Binding VettedPos1, Mode=TwoWay}"/>

    When I change the value in the dropdown, the selected index (dg.SelectedIndex) in the code behind is -1.

    Any help much appreciated!!

  21. charley sheng says:


    I have used the datagrid to create the template by using the template column and put customized control into the column. drap visula control into single cell of data grid worked fine, but didn’t work for multiple selected cells. any suggestion?


    charley sheng

  22. Charley,

    "drap visula control into a single cell" => "drag visual control into a single cell"?  Could you expand on this a little bit.  I’m not quite sure what you mean.

  23. Charley sheng says:


    thank you for yor reply. the DataGrid is used as drop target object and drag some other control, like, button,content tempaltes,… into the datagrid cell or cells. if single cell is slected, the draging is working as expected, but if multiple cells are selected and drag control into the cells, nothing happened. the drag data objects could be seen in the debug but there is not any UI presentation could be seen on the screen.


    charley sheng

  24. Charley sheng says:


    I have figured out what the cause is and the problem is fixed.


    charley sheng

  25. AJJohn123 says:

    Is there an example showing how to have nested dataGrids (e.g. have a master DataGrid with 2 columns, but I want o have each row to be expanded to show another data grid .

  26. AJJohn123,

    You can nest a DataGrid in the RowDetailsTemplate.  When you select a row it should display that nested DataGrid.

  27. _ivan says:

    AutoGenerateColumns="True" doesn’t work for

    public IEnumerable<ClientAudit> Audit

    where ClientAudit is an entity in LINQ to SQL.

    When I bind columns manually it works, but I have like 100 tables, and thought it would be nice to just drop a data grid and it will find columns automatically.

  28. _ivan says:

    AutoGenerateColumns="True" does work with POCO classes though. So I am confused why it’s not working.

    Here is XAML



                           ItemsSource="{Binding Path=Audit, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"











                           AlternatingRowBackground="{StaticResource HorizontalBrush}"


                           ColumnHeaderStyle="{StaticResource dgHeaderStyle}"


Comments are closed.

Skip to main content