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