我可以帮您翻译成中文。以下是需要翻译的内容:
当我修改“ProductName”并按下“取消”按钮时,属性将重置为传递的参数。但如果我修改ProgramIds(添加或删除)并按下“取消”按钮,则集合不会设置为传递的值。为什么?
在我的ViewModel中,我有:
[Model]
[Catel.Fody.Expose("ProductName")]
[Catel.Fody.Expose("ProgramIds")]
Public ProgramDataModel DataModel
{
get { return GetValue<ProgramDataModel>(DataModelProperty); }
set { SetValue(DataModelProperty, value); }
}
模型中:
public string ProductName
{
get { return GetValue<string>(ProductNameProperty); }
set { SetValue(ProductNameProperty, value); }
}
public static readonly PropertyData ProductNameProperty = RegisterProperty(nameof(ProductName), typeof(string));
public ObservableCollection<ProgramIDModel> ProgramIds
{
get { return GetValue<ObservableCollection<ProgramIDModel>>(ProgramIdsProperty); }
set { SetValue(ProgramIdsProperty, value); }
}
public static readonly PropertyData ProgramIdsProperty = RegisterProperty(nameof(ProgramIds), typeof(ObservableCollection<ProgramIDModel>));
在 MainViewModel 中:
var viewModel = new ProductWindowViewModel(DataViewModel);
await _uiVisualizerService.ShowDialogAsync(viewModel);
public ProgramDataModel DataModel {get; set;}
。 - Geert van Horrik