c# - WPF: Updating private setter variable IS not raising propertyChanged event handler -
my view model has next code. i'm using mvvmlight
class settingsviewmodel : viewmodelbase { public settingsviewmodel() { } string _customername; public string customername { { homecoming _customername; } set { if (_customername == value) return; _customername = value; raisepropertychanged("customername"); } } private void _changenameprivate() { this._customername = "someprivatename"; } private void _changenamepublic() { this.customername = "somepublicname"; } }
my question when phone call _changenameprivate
raisepropertychanged
event handler not raised. it's raised when phone call _changenamepublic
function. shouldn't updating private variable raise property changed event ?
as @dkozl , @ben said, expected:
the code provided, phone call raisepropertychanged
event handler in set section of customername
property:
public string customername { { homecoming _customername; } set { if (_customername == value) return; _customername = value; raisepropertychanged("customername"); } }
as such, in _changenamepublic()
changes value of property phone call set section , raise raisepropertychanged
handler. in _changenameprivate()
, assign value field _customername
.
c# wpf mvvm
No comments:
Post a Comment