WPF+MVVM的有关问题
WPF+MVVM的问题<br />
我现在有点小疑惑了,恩,就是跨类添加数据的时候出现了一个小问题。
首先是父类的代码。
//实现功能的方法
public void addCompanyCommand()
{
AddCompanyInfo add = new AddCompanyInfo();
add.addDataEvent += new AddDataDelegate(addevenData);
add.ShowDialog();
//AddCompanyInfoViewModel addcompany = new AddCompanyInfoViewModel();
//addcompany.addDataEvent += new addDataDelegate(addevenData);
//addcompany.ShowView();
//addcompany.addData += new AddCompanyInfoViewModel.AddData(addevenData);
//add.ShowDialog();
//IBaseViewModel view = new AddCompanyInfo();
//view.Show();
}
子类的方法
namespace OptWpfApp
{
public delegate void addDataDelegate(CompanyInfoModel model);
public class AddCompanyInfoViewModel : BaseViewModel, INotifyPropertyChanged
{
public event addDataDelegate addDataEvent;
public AddCompanyInfoViewModel()
{
_addCompanyCommand = new RelayCommand(addCompanyCommand) { IsEnabled = true };
}
//public void ShowView()
//{
// AddCompanyInfo add = new AddCompanyInfo();
// add.ShowDialog();
//}
public void showViewEvent()
{
}
//实现功能的方法
public void addCompanyCommand()
{
CompanyInfoModel model = new CompanyInfoModel()
{
CompanyNo = CompanyNo,
CompanyName = CompanyName,
RegisteredAddress = RegisteredAddress,
OfficeAddress = OfficeAddress,
CorporateRepresentative = CorporateRepresentative,
RegisteredCapital = RegisteredCapital,
ScopeBusiness = ScopeBusiness,
Code = Code,
CompanyCreateTime = CompanyCreateTime,
YingYeStartTime = YingYeStartTime,
YingYeEndTime = YingYeEndTime
};
//if (addDataEvent != null)
//{
// addDataEvent(model);
//}
// addData += new AddData(model);
//if (addData != null)
//{
// addData(model);
//}
相关链接