I use Caliburn.Micro and I have 2 View and relative 2 ViewModel:
- MainView (MainViewModel)
- BView (BViewModel)
In BView i have a DataGrid and in BView a method to fill DataGrid. In MainView there is a Botton, I want you to click the button to open the window BView and call the methot to fill the DataGrid (the method name is:AllArticles).
So when I click the button (in MainWiew) will open BView with DataGrid filled.
The MainViewModel code is:
[Export(typeof(IShell))]
public class MainViewModel : Screen
{
public string Path{ get; set; }
public void Open()
{
OpenFileDialog fd = new OpenFileDialog();
fd.Filter = "Text|*.txt|All|*.*";
fd.FilterIndex = 1;
fd.ShowDialog();
Path= fd.FileName;
NotifyOfPropertyChange("Path");
}
}
The BViewModel code is:
public class BViewModel : Screen
{
public List<Article> List { get; private set; }
public void AllArticles()
{
Recover recover = new Recover();
List = recover.Impor().Articles;
NotifyOfPropertyChange("List");
}
}
What should I do?