Hi I have a silverlight MVVM application using MVVM light.
When I open the application a child window should popup and upon specifying the condition in the child window and clicking OK button the main window should display the details.
public MainPage()
{
ChildPage cp = new ChildPage();
cp.Show();
InitializeComponent();
}
upon hitting OK button on the child window this window should disappear and display a list of objects on the main window. In the View Model of the child window I have a RelayCommand OKCommand.
private void WireCommands()
{
OKCommand = new RelayCommand(GetEmployees);
}
private void GetEmployees()
{
IEnumerable<Employees> employees;
employees = from employee in Employees where employee.Name == selectedEmployee.Name select employee;
Employees= new ObservableCollection<Employee>(employees);
}
The Employees has the required result. But I dont know how to close the chils window and move the result to the parent window. Thanks in advance.
You can use (in increasing order of decoupling):
Using .NET Events
Using Event Aggregator from Caliburn.Micro
Here we are doing the employee retrieval in the MainPage, after receiving the name from the ChildPage. Alternatively, you could retrieve the employees in the ChildPage, and pass them in the event args/message.