-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
No calls to OnXXXChanged event handlers on Avalonia.StyledProperty #12
Comments
//HintName: MyControl.StaticConstructor.generated.cs
using System;
#nullable enable
namespace H.Generators.IntegrationTests
{
public partial class MyControl
{
static MyControl()
{
IsSpinningProperty.Changed.Subscribe(static x =>
{
((global::H.Generators.IntegrationTests.MyControl)x.Sender).OnIsSpinningChanged(
(bool)x.OldValue.GetValueOrDefault(),
(bool)x.NewValue.GetValueOrDefault());
});
}
}
} In addition to the main properties file for Avalonia, a static constructor is also generated that calls the OnChanged methods. Please let me know if there are any problems with this. |
Yes, I added integration tests for this case and it doesn't really call the methods. I will research this |
Thanks for the fast response - Preview 5 and 6 broke a lot of things. For now the workaround is to manually override |
Yes, they changed the Subscribe method and now it does not contain data about the sender, old and new value. But the option via overriding OnPropertyChanged will not work for attached properties. |
Describe the bug
When creating a
StyledProperty
via for example:[DependencyProperty<int>("SelectedType")]
The resulting generated code does never call the
OnSelectedTypeChanged(...)
event handler, subsequently no event notifications when the value changes are received.The same property as a
DirectProperty
:[DependencyProperty<int>("SelectedType", IsDirect = true)]
contains the necessary calls on all versions of the
OnSelectedTypeChanged(...)
event handler in the property setter.I understand that event handlers for value changes have become a bit cumbersome, as the
notifying
parameter has become internal (as of Avalonia 11 preview 6), and as such is not available anymore. The preferred route to receive event notifications is to either override theOnPropertyChanged
method, or attach to thePropertyChange
event. (as per Max Katz from AvaloniaUI core developer team)Steps to reproduce the bug
Create
StyledProperty
in an Avalonia project and try to listen for value changes, which will not fire.Expected behavior
No response
Screenshots
No response
NuGet package version
1.2.5
IDE
Visual Studio 2022
Additional context
No response
The text was updated successfully, but these errors were encountered: