I have a set of items that need to populate a set of TextBox
's on a page. Every time the user clicks on a different item I want to remove the old binding from the last item and set the new bindings for the current item. If I don't do this a WinRT The object is immutable
exception is thrown.
This code works when the first item is selected but throws an exception on the next item selection.
titleBinding.Source = selectedItem;
TitleBox.SetBinding(TextBox.ValueProperty, _titleBinding);
You could try calling ClearValue.
TitleBox.ClearValue(TextBox.ValueProperty);
The solution for me was to create completely new binding objects each time a new item loaded and then call TitleBox.SetBinding(TextBox.ValueProperty, newBindingObject);
Apparently you can't unbind a Binding
object after the source has been set and it has been binded to an object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With