This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi there, I am using WPF Element Apr. 3rd 2012 nightly build. I have a question in DataGrid on how to set the ComboBox ItemsSource in a column. Here are some code snipts: 1) I have a ViewModel
2) On XAML I have something like:
I defined ageTemplate as the following
In the code behind xaml on the constructor I have set this.DataContext = new VMCustomer() after InitailizeComponet(); But when I run the application the drop down for the Age combobox column is empty. I don't want to put the Ages property inside the Customer class, how do I make it work? |
|
|
Hello Gordon The data context of the cell is the row object (a Customer) which means the editor template does not have access to the Ages property in your current setup. I would recommend that you set the Ages property to be static. (This of course means the ages field should also be static, and it can be loaded with strings in the static constructor). Then in the editor template, you can set the ItemsSource of the combo box like this:
Where 'local' is the namespace containing VMCustomer. Jason Fauchelle |
|