mvvm - Silverlight OneWay binding -
let's assume have text box on form , enabled (user can type whatever want.) there oneway binding set string property when viewmodel changes property text box updates. happens when user changes value in text box manually. binding overwritten new value of text box? or remember value , keep binding, when update property next time in viewmodel change reflect in ui?
public class vm : inpcbase { private string _mytext; public string mytext { { return _mytext; } set { _mytext = value; this.notifypropertychanged(()=>mytext);} } public void blup() { this.mytext = "blup"; } } public partial class mainwindow : window { private vm data = new vm(); public mainwindow() { initializecomponent(); data.mytext = "sdfjksj"; this.datacontext = data; } private void button1_click(object sender, routedeventargs e) { this.data.blup(); } }
xaml
<textbox text="{binding mytext, mode=oneway}"/> <button click="button1_click" />
binding still works no matter if user change value manually. user never value view viewmodel, because oneway
Comments
Post a Comment