Q:

UWP: Replacing data binding

I have a very weird problem. If I've set the binding and change the binding to another property, it will not work.
Look at this simple example
lblTotal.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("Subtotal"), Source = Order, Mode = BindingMode.OneWay });
lblTotal.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("FinalTotal"), Source = Order, Mode = BindingMode.OneWay });

When the FinalTotal is changed, the lblTotal text will NOT be changed. 
Now, commented out the first line.
//lblTotal.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("Subtotal"), Source = Order, Mode = BindingMode.OneWay });
lblTotal.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("FinalTotal"), Source = Order, Mode = BindingMode.OneWay });

NOW IT WORKED!!!! Changing FinalTotal will change the lblTotal text! Any idea why?
Also, BindingOperations.ClearBinding() is not available in UWP. So I've tried to replace it with empty binding and it still doesn't work.
lblTotal.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("Subtotal"), Source = Order, Mode = BindingMode.OneWay });

//remove binding - not sure if this is correct way to remove binding because
//BindingOperations.ClearBinding() isn't available in UWP!
BindingOperations.SetBinding(lblTotal, TextBlock.TextProperty, new Binding());

lblTotal.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("FinalTotal"), Source = Order, Mode = BindingMode.OneWay });

My questions are:
1. How to replace the binding in UWP?
2. How to remove the existing binding in UWP (ie. equivalent function to BindingOperations.ClearBinding())?
Thanks for any help...

A:

As it is declared in FrameworkElement.SetBinding method:

Note  Calling the SetBinding method and passing in a new Binding object won't necessarily remove an existing binding. Instead, you should first call the DependencyObject.ClearValue method, then call SetBinding.

So you can change your code like following:
lblTotal.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("Subtotal"), Source = Order, Mode = BindingMode.OneWay });
lblTotal.ClearValue(TextBlock.TextProperty);
lblTotal.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("FinalTotal"), Source = Order, Mode = BindingMode.OneWay });

After this your code should be able to work. For more info, please see Remarks of FrameworkElement.SetBinding and also BindingOperations.SetBinding.

