I have a custom DepenencyProperty which determines a UserControl’s visibility. It is usually bound to a boolean value, however I would like to set it False when the Escape key is hit.
The problem is, I don’t want to overwrite the binding, I want to update the bindings source value. How can I do this in code behind?
For example, with this XAML
<local:MyControl IsVisibile="{Binding IsControlVisible}" />
I want to update the value of IsControlVisible to false, not MyControl.IsVisible
This should be possible via
BindingExpressions, try something like this:(If you do not reuse the
UIElement.IsVisiblePropertyyou need to specify it viaMyControl.IsVisiblePropertyof course)Here is a reflection-using method: