Replies: 1 comment 1 reply
-
When you subscribe to an static MyControl()
{
ExampleProperty.Changed.Subscribe(OnExampleChanged);
}
private static void OnConditionChanged(AvaloniaPropertyChangedEventArgs args)
{
if (args.Sender is not MyControl myControl)
return;
myControl.DoSomething();
} See Avalonia/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs Lines 368 to 370 in 9e24f9b For personal projects, you'll need to bridge the observable to Avalonia, too, with something like: using Avalonia.Reactive;
using System;
namespace MyApp;
internal static class ObservableExtensions
{
public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> action)
{
return source.Subscribe(new AnonymousObserver<T>(action));
}
}
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
how/where is AvaloniaPropertyChangedEventArgs ever used ?
OnPropertyChanging takes a PropertyChangingEventArgs which is not castable to AvaloniaPropertyChangedEventArgs.
I am trying to access old/new values which are properties of AvaloniaPropertyChangedEventArgs but not PropertyChangingEventArgs
Beta Was this translation helpful? Give feedback.
All reactions