0
我使用mvvmlight,我觉得默认的实现(从mvvminpcmsg的代码片段)的INPC的是:为什么mvvmlight默认实现中的公共常量字符串属性?
/// <summary>
/// The <see cref="MyProperty" /> property's name.
/// </summary>
public const string MyPropertyPropertyName = "MyProperty";
private bool _myProperty = false;
/// <summary>
/// Sets and gets the MyProperty property.
/// Changes to that property's value raise the PropertyChanged event.
/// This property's value is broadcasted by the MessengerInstance when it changes.
/// </summary>
public bool MyProperty
{
get
{
return _myProperty;
}
set
{
if (_myProperty == value)
{
return;
}
RaisePropertyChanging(MyPropertyPropertyName);
var oldValue = _myProperty;
_myProperty = value;
RaisePropertyChanged(MyPropertyPropertyName, oldValue, value, true);
}
}
我不知道为什么添加了公共常量字符串?
public const string MyPropertyPropertyName = "MyProperty";
我不认为它是inpc实现所必需的,我也没有看到它的任何用法。 那么为什么加入?
但为什么它是'公共'? – Felix 2014-11-04 09:10:41
@费:不知道那个。 – 2014-11-04 16:01:50