If I have a DependencyObject
with a OneWayToSource
Binding
set on one property and then try to set the DP's value again, the Binding
is being removed.
I can not use the 'reversed' way with a direct (normal) Binding, so I have to use a OneWayToSource Binding. My question is whether there is another way to achieve this.
Asked
Active
Viewed 126 times
1

g t
- 7,287
- 7
- 50
- 85

HerpDerpington
- 3,751
- 4
- 27
- 43
1 Answers
2
Let me see if I understand correctly, you have something like this:
<SomeControl x:Name="MyControl" MyProp="{Binding Something, Mode="OneWayToSource"}".../>
Then, in code-behind, you try to set MyProp
to some other value
MyControl.MyProp = SomethingElse;
And now changes to MyProp
are not updating Something
because binding is removed. Right?
In that case, and if you work under .NET 4.0 or above, you can use SetCurrent
:
MyControl.SetCurrent(MyPropProperty, SomethingElse);

XAMeLi
- 6,189
- 2
- 22
- 29
-
Great! I would never have found this. I wonder whether there is a way in other .NET versions... – HerpDerpington Dec 17 '13 at 15:47
-
1Was added at 4.0. It was greatly missed till then. IIRC, there were some ways but they were messy. – XAMeLi Dec 17 '13 at 22:22