New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] WhenAny[Value] does not fire on DependencyProperty if INotifyPropertyChanged is implemented #3111
Comments
Interesting. If i were to modify the CustomControlThatDoesNotWork with the following:
Would you expect it to fire twice for every set? |
The problem is you are changing the behavior of a dependency property. You should know that the It will work for most cases but does not handle the problem correctly and will not for 100% of the cases. |
This is deliberate functionality on our parts but can be overridden. The INPC votes 5 that it can handle the property changed
You could make your own https://github.com/reactiveui/ReactiveUI/blob/00b48d37f49022e49fd105bb6a1d737f1c237c2b/src/ReactiveUI.Wpf/DependencyObjectObservableForProperty.cs and register with Splat.
I might make our version have a virtual method on the voting to allow you to derive.
|
No sorry. I didnt mean to suggest it was a solution to your problem. I was trying to hint that DependencyObjects and INotifyPropertyChanged use two different mechanisms for providing property change events. I would really try to avoid to combine a View Model and a Control in one object (MVVM separates theese).
In the above code, a WPF binding would only hit on the first line, and ignore the second line since it checks for DependencyProperty first. |
Describe the bug
I am trying to use
this.WhenAnyValue
to observe changes to a customDependencyProperty
of aUserControl
.UserControl
does not implementINotifyPropertyChanged
,this.WhenAnyValue
fires as forseen.UserControl
does implementINotifyPropertyChanged
,this.WhenAnyValue
fires once and never after.Step to reproduce
These two classes only differ by the
INotifyPropertyChanged
. They will change theDependencyProperty
Value
every 2s.UserControl
named "UserControlTest" that will use both of those classesUserControlTest.xaml.cs
TextBlock
textblock1
andtextblock2
will update their "Text" property because theDependencProperty
is well set.Expected behaviour
This line
this.WhenAnyValue(x => x.custom2.Value).Subscribe(x => Console.WriteLine(x)).DisposeWith(d);
should fire every 2s as the others.Environment
The text was updated successfully, but these errors were encountered: