【发布时间】:2016-02-18 10:47:53
【问题描述】:
我想在属性更改时运行一个方法。我希望我的代码编译成这样的:
public string Property
{
get { return _property; }
set
{
_property= value;
IWantToCallFromHere(); // I want to inject this call
NotifyPropertyChanged();
}
}
【问题讨论】:
-
此代码必须由来自
public string Property { get; set; }的foddy生成 -
我刚读到关于 Fody 的文章。让我帮助理解它。如果我们只是用get set编写公共属性,那么编译器会自动为我们生成代码吗?如果我想在我的 Set 属性中执行任何逻辑,那么我将在哪里使用 Fody 编写?我们可以编辑 Fody 自动生成的代码吗?
标签: c# mvvm inotifypropertychanged fody-propertychanged