c# - WPF Binding to behave OneWayToSource and OneTime -



c# - WPF Binding to behave OneWayToSource and OneTime -

is possible command binding behave onewaytosource , onetime?

here background: have info grid. each row has text cells , checkbox. if checkbox selected info row saved. now, when user starts typing in text cell alter ischecked property in viewmodel checkbox gets checked. happen once. so, example, if user starts typing , decides uncheck checkbox don't want alter when user start typing value again.

sounds me setting binding both onewaytosource , onetime should solution know binding mode can set single value. i've been searching suggestions , possible workarounds accomplish similar result no result.

from msdn:

onetime updates target property when application starts or when datacontext undergoes change

that means using combination of onewaytosource , onetime not solve issue 'one time'-update not trigger moment property changes first time on application start or datacontext change.

as bound text cell text property can command in property if ischecked should set or not.

private string text_ = ""; private bool ischecked_ = false; private bool autosetchecked_ = true; public bool ischecked { { homecoming ischecked_; } set { if (ischecked_ == value) { return; } // if user manually changes check state assume user wants maintain state // => disable auto changing. autosetchecked_ = false; ischecked_ = value; onpropertychanged("ischecked"); } } public text { { homecoming text_; } set { if (text_ == value) { return; } text_ = value; onpropertychanged("text"); if (autosetchecked_) { // set checked if not done ever before. autosetchecked_ = false; ischecked = true; } } }

edit: requires ischecked-binding twoway can alter checkbox viewmodel.

c# wpf binding

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -