1

I guest similar questions to this one could have been asked, I still need an answer or example. I need to make sure that, the built-in WPF Datagrid, does it support combobox column editing or not? If it does, please provide me a working example. Though I may find several, even a lot, they have some of the following problem:

1.Outdated, cannot compile with the current Visual Studio (2013 or 2015)

2.Not working

3.Needs a 3rd party control, like WPF Toolkit. This is even more confusing. I may find a lot of different versions, and not working as well. Right now I only want to know whether the built in Datagrid may work or not.

4.combobox options not from a Key-Value list (or some other list). I know I need to specify SelectedItemBinding, SelectedValueBinding, SelectedValuePath, isplayMemberPath. It is so confusing. I just can't get it work.

I've tried ObservableCollection. Do not what went wrong. If you have a really work sample, please just reply me with the code. Thanks!

Zach Rattner
  • 20,745
  • 9
  • 59
  • 82
Thomas Mao
  • 23
  • 2
  • 7
  • You want to bind DataGrid.ItemsSource to an ObservableCollection of whatever model class represents your row data. Bind with a `{Binding ...}` in XAML, don't mess around in codebehind. For a combobox column, [this question and its answer](http://stackoverflow.com/questions/5409259/binding-itemssource-of-a-comboboxcolumn-in-wpf-datagrid) should get you over the hump. – 15ee8f99-57ff-4f92-890c-b56153 Apr 13 '16 at 02:42
  • However, in this example, if I need to use DataGrid RowEditEnding event to capture the changed combobox value, I found it never changed, no matter I try to get it from the view model or the grid. What anything else should I make up? (by the way, using WpfToolkit won't be allowed to have RowEditEnding event, need to restore to the VS built in DataGrid). – Thomas Mao Apr 17 '16 at 03:12
  • I'd need to see the code to say anything about it. Show code please, please. In XAML you need to learn to think in terms of data binding, not events. You don't need any events to do anything. You need data binding. Avoid third party anything if possible. BTW I don't know what means "need to restore to the VS built in DataGrid". Looks like random word sequence to me. Can you clarify? Thanks! – 15ee8f99-57ff-4f92-890c-b56153 Apr 17 '16 at 03:49
  • 1
    oh, I just found the problem myself. The Binding should be , {Binding status, UpdateSourceTrigger=PropertyChanged}. Now it works fine fine fine. I appreciate that! – Thomas Mao Apr 17 '16 at 03:55
  • Awesome! Glad to hear it! – 15ee8f99-57ff-4f92-890c-b56153 Apr 17 '16 at 03:56
  • @NoamM Yeah, I can see you put in a lot of hard work on that one. – 15ee8f99-57ff-4f92-890c-b56153 Apr 17 '16 at 16:42

1 Answers1

1

As metioned by @Ed Plunkett in the comments, use this answer which have a great Datagrid with combobox column example

Community
  • 1
  • 1
Noam M
  • 3,156
  • 5
  • 26
  • 41