Binding Mode for user control with ListBox within

I had a ListBox with Binding set on SelectedItem without explicitly setting it to TwoWay mode. Still this worked in two way mode without issues. When I moved that ListBox inside a usercontrol that’s when the binding stopped two way.

All i did was move the Listbox in usercontrol and created a dependency property in usercontrol to surface its properties to outside world. Internally usercontrol was binding to this dependency property using RelativeSource parent and externally we were just using the same binding code and assigning it to our newly created dependency property surfaced by usercontrol. Still, the default TwoWay binding stopped and I had to manually set mode=TwoWay to make it work.

Just a thought if somebody is wondering on the same issue.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s