开发者

MVVM Property databinding

Why do most MVVM databinding properties examples check to see if the current value is equal to previous.开发者_Go百科

private string name;
public string Name
{
  set 
  {
    if(this.name != value) <- why is this check needed.   
    {...}  
  }  
}

thanks!


In MVVM a property setter triggers the UI update following a property change. Adding this check prevents the UI to refresh (and possibly flicker) unnecessarily.


In the case of a Binding "TwoWay", When changing the value in the XAML, the value in the bound property in the ViewModel side must not re-send the same value. On the other hand if the value (ViewModel bind side) is not changed it is not necessary to throw the "RaiseChangedProperty" event to the View.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜