I need help with binding. Its WPF MVVM pattern. I have placed a datagrid and three ICommand buttons 'Add', 'Modify', 'Delete' buttons, in a UserControl (UC). The add, modify, delete buttons are to facilitate operations to the datagrid. Calling this UC 5 times in a XAML window (Main window). The button controls are handled in the view model of the main XAML window. For instance, AddStudent for Add button, ModifyStudent for Modify button and DeleteStudent for Delete button. But there is only one handler for all the 5 instance of the UC. For instance, click on the Add button from any of the 5 instances of the UC, it calls the same AddStudent function.
But the problem is, the 5 UC instance has to bind to 5 different Students class, Engineering, Medical, Architecture and so on.
here is Student entity containing student details.
So when I click on the Medical Student datagrid's Add button, a dialog would popup asking for student details that should be inturn added to the Medical Student's datagrid. Same goes to other 4 datagrids. All these should be done in view model. But the problem is, since all the 5 instances call the same AddStudent method, the new student added is reflecting in all 5 datagrids. I want to be able to bind the respective Student list to its corresponding datagrid control. Need help with the binding. PS: I have made the ITemsSource of the UC a Dependency Property.
Student is not an interface. Its an entity class.
public class College
{
private string code;
private string name;
private Student engineering;
private Student medical;
private Student nursing;
private Student architecture;
private Student fashionDesign;
public Student Engineering
{
get
{
return engineering;
}
set
{
SetField(ref engineering, value, () => Engineering);
}
}
}
Where Student is a class. Unfortunately, I dont have the liberty to change it to an Interface. Any other way to bind each of these to its corresponding datagrid.