![](/img/trans.png)
[英]Catel InterestedIn OnViewModelCommandExecuted check which command executed
[英]Problems with Catel in WPF, InterestedIn ViewModel reloading
因此,我有一个名为NewBonusCalculationViewModel的视图模型。 此视图模型对其他一些视图模型感兴趣,这些视图模型在NewBonusCalculationViewModel中用作选项卡。
NewBonusCalculationViewModel感兴趣的选项卡之一称为GeneralTabVM。 此GeneralTabVM具有一个称为GeneralTabDataModel的数据模型,该数据模型中的属性与GneralTabVM(ViewModelToModel)映射。
在GeneralTabDataModel中,我有一个名为BeginningTime的属性,当我打开NewBonusCalculationViewModel页面并按下X按钮(不进行任何更改)时,viewmodel会重置BeginningTime属性的值,这会引发IsModelDirtyChanges,而我得到的问题是“要保存更改?”。
我找不到导致ViewModel重置或重新加载的原因。 我正在使用Catel 4.4。
我尝试删除映射,interestedIn,甚至删除属性BeginningTime(并使用Model.StartingTime),但似乎无济于事。
这是我从NewBonusCalcVieModel加载GeneralTab道具的方式:
generalModel = new GeneralTabDataModel
{
Header = Client.Common.GetText(456),
Id = LohnStatList[0].Id,
Descript = LohnStatList[0].Descript,
IdGroup = LohnStatList[0].IdGroup,
IdStation = LohnStatList[0].IdStation,
SelectedStationName = this.AllStations.FirstOrDefault(w => w.IdStation == LohnStatList[0].IdStation).Name,
NWhichTime = this.NWhichTime[0].Id,
Period = Nomenclature.Period,
LohnStatList = LohnStatList,
CanEditTab = this.CanEditTabs
};
this.prevName = LohnStatList[0].Descript;
this.generalModel.PropertyChanged += GeneralModel_PropertyChanged;
this.BonusTabsList.Add(generalModel);
这是GeneralTabVM的构造函数:
public GeneralTabViewModel(GeneralTabDataModel model) : base(model)
{
this.IsLoadingData = true;
this.SelectBonusTypeCommand = new Command(this.OnSelectBonusTypeCommandExecute);
this.SelectStationCommand = new Command(this.OnSelectStationCommandExecute);
this.SelectedStationName = model.SelectedStationName;
this.Model = model;
this.Model.Descript.Trim();
this.LoadData();
this.Model.AcceptChanges();
this.Model.PropertyChanged += Model_PropertyChanged;
this.IsLoadingData = false;
}
您使用的版本过旧(从2015年11月开始)。 请升级到至少5.x(于2016年7月发布)以获得可靠的答案。
即使您发现了一个错误,团队也不会在这样的旧版本中修复它。 此外,在Catel中已删除了InterestedIn
功能,以支持服务或MessageMediator
。
如果不这样做,我建议使用另一种通信技术来解决该问题(例如服务)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.