문제

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.

도움이 되었습니까?

해결책

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top