Is it possible to set the value behind a two-way binding directly, without knowing the bound property?
I have an attached property that is bound to a property like this:
<Element my:Utils.MyProperty="{Binding Something}" />
Now I want to change the value that is effectively stored in Something
from the perspective of the attached property. So I cannot access the bound property directly, but only have references to the DependencyObject
(i.e. the Element instance) and the DependencyProperty
object itself.
The problem when simply setting it via DependencyObject.SetValue
is that this effectively removes the binding, but I want to change the underlying bound property.
Using BindingOperations
I can get both the Binding
and the BindingExpression
. Now is there a way to access the property behind it and change its value?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…