-2

i have an combobox and datagrid when user select a data from combobox the grid will be populated according to that using MVVM and entity framework

Advance thanks

Nadeem
  • 651
  • 1
  • 13
  • 26
  • Code you have tried ? Datasources ? Linq ? – squelos Mar 08 '12 at 19:01
  • Take a look at [http://stackoverflow.com/questions/2511177/how-to-bind-a-table-in-a-dataset-to-a-wpf-datagrid-in-c-sharp-and-xaml](http://stackoverflow.com/questions/2511177/how-to-bind-a-table-in-a-dataset-to-a-wpf-datagrid-in-c-sharp-and-xaml) – Raj Ranjhan Mar 08 '12 at 19:01

1 Answers1

0

In your ViewModel, create a SelectedItem property which notifies on change as so:

private object _selectedItem
public object SelectedItem
{
    get
    {
        return _selectedItem;
    }
    set
    {
        _selectedItem = value;
        OnPropertyChanged("SelectedItem")
    }
}

Bind your SelectedItem property of your combo box to this property.

Then watch for a change on SelectedItem and change your datagrid's source property accordingly.

Khan
  • 17,904
  • 5
  • 47
  • 59
  • 1
    What about my question did you not get? What do you need me to elaborate more on? – Khan Mar 08 '12 at 19:37
  • 1
    @Nadeem - Please use Google. This forum is not meant to hand-feed you your project, especially when you don't provide any details yourself. – Wonko the Sane Mar 08 '12 at 19:46
  • @Wonko the Sane this forum is to get answer of your problem i am new in WPF so i dnt know i search out also bt.. if you not want want to answer then ignore no need to pass comments – Nadeem Mar 09 '12 at 04:21
  • I have a question about this. I have my Combobox populated already with a list property I created. The combobox is populated with a column from my db. I want to be able to select a string from the list in combobox and then have my datagrid populate with other columns from db that are not the combobox property but other properties that share the unique combobox property. I was thinking, should I use linq to fetch all the other columns from db that contain the unique combobox property on selection and then bind that property to datagrid. Does that sound right? – Kala J May 07 '14 at 15:36