【发布时间】:2013-03-24 18:01:24
【问题描述】:
我使用 Caliburn.Micro,我有 2 个 View 和相对的 2 个 ViewModel:
- 主视图(MainViewModel)
- BView (BViewModel)
在 BView 中有一个 DataGrid,在 BView 中有一个填充 DataGrid 的方法。 在MainView中有一个Botton,我要你点击按钮打开BView窗口并调用填充DataGrid的方法(方法名称为:AllArticles)。
因此,当我单击按钮(在 MainWiew 中)时,将打开填充了 DataGrid 的 BView。
MainViewModel 代码为:
[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");
}
}
BViewModel 代码为:
public class BViewModel : Screen
{
public List<Article> List { get; private set; }
public void AllArticles()
{
Recover recover = new Recover();
List = recover.Impor().Articles;
NotifyOfPropertyChange("List");
}
}
我该怎么办?
【问题讨论】:
标签: c# wpf view caliburn.micro