c# - How can I programmatically bind this CheckBox? -
this code in class constructor:
checkbox autoscrollcheckbox = new checkbox(); autoscrollcheckbox.verticalalignment = verticalalignment.center; autoscrollcheckbox.content = "enable"; binding autoscrollbinding = new binding(); autoscrollbinding.path = new propertypath("autoscrollingisenabled"); autoscrollbinding.relativesource = new relativesource(relativesourcemode.self); autoscrollbinding.mode = bindingmode.twoway; autoscrollcheckbox.setbinding(checkbox.ischeckedproperty, autoscrollbinding); autoscrollbox.content = autoscrollcheckbox;
this in same class:
public bool autoscrollingisenabled { { return !autoscrollingispaused; } set { autoscrollingispaused = !value; } }
but autoscrollingisenabled never called. problem?
you should setting source not relative source.
autoscrollbinding.source = this;
but if want update code reflected on window you'll need implement inotifyproertychanged @evanb mentioned.
Comments
Post a Comment