diff --git a/samples/AppWithoutLifetime/MainWindow.axaml.cs b/samples/AppWithoutLifetime/MainWindow.axaml.cs
index d27d5d5653..df3ed3cea0 100644
--- a/samples/AppWithoutLifetime/MainWindow.axaml.cs
+++ b/samples/AppWithoutLifetime/MainWindow.axaml.cs
@@ -17,10 +17,11 @@ public partial class MainWindow : Window
AvaloniaXamlLoader.Load(this);
}
- protected override void OnLoaded()
+ ///
+ protected override void OnLoaded(RoutedEventArgs e)
{
this.AttachDevTools();
- base.OnLoaded();
+ base.OnLoaded(e);
}
public void Open(object sender, RoutedEventArgs e)
diff --git a/samples/AppWithoutLifetime/Sub.axaml.cs b/samples/AppWithoutLifetime/Sub.axaml.cs
index 50c770b3a2..3a7ce787bc 100644
--- a/samples/AppWithoutLifetime/Sub.axaml.cs
+++ b/samples/AppWithoutLifetime/Sub.axaml.cs
@@ -1,5 +1,6 @@
using Avalonia;
using Avalonia.Controls;
+using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
namespace AppWithoutLifetime;
@@ -16,9 +17,10 @@ public partial class Sub : Window
AvaloniaXamlLoader.Load(this);
}
- protected override void OnLoaded()
+ ///
+ protected override void OnLoaded(RoutedEventArgs e)
{
this.AttachDevTools();
- base.OnLoaded();
+ base.OnLoaded(e);
}
}
diff --git a/samples/SafeAreaDemo/Views/MainView.xaml.cs b/samples/SafeAreaDemo/Views/MainView.xaml.cs
index 2b651225e7..4b8c5e5f15 100644
--- a/samples/SafeAreaDemo/Views/MainView.xaml.cs
+++ b/samples/SafeAreaDemo/Views/MainView.xaml.cs
@@ -1,4 +1,5 @@
using Avalonia.Controls;
+using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using SafeAreaDemo.ViewModels;
@@ -11,9 +12,10 @@ namespace SafeAreaDemo.Views
AvaloniaXamlLoader.Load(this);
}
- protected override void OnLoaded()
+ ///
+ protected override void OnLoaded(RoutedEventArgs e)
{
- base.OnLoaded();
+ base.OnLoaded(e);
var insetsManager = TopLevel.GetTopLevel(this)?.InsetsManager;
if (insetsManager != null && DataContext is MainViewModel viewModel)
diff --git a/src/Avalonia.Controls/Control.cs b/src/Avalonia.Controls/Control.cs
index ae7d4f3fb4..6c45374c21 100644
--- a/src/Avalonia.Controls/Control.cs
+++ b/src/Avalonia.Controls/Control.cs
@@ -316,7 +316,8 @@ namespace Avalonia.Controls
((ILogical)this).IsAttachedToLogicalTree)
{
_isLoaded = true;
- OnLoaded();
+
+ OnLoaded(new RoutedEventArgs(LoadedEvent, this));
}
}
@@ -333,28 +334,27 @@ namespace Avalonia.Controls
_loadedQueue.Remove(this);
_isLoaded = false;
- OnUnloaded();
+
+ OnUnloaded(new RoutedEventArgs(UnloadedEvent, this));
}
}
///
/// Invoked just before the event.
///
- protected virtual void OnLoaded()
+ /// The event args.
+ protected virtual void OnLoaded(RoutedEventArgs e)
{
- var eventArgs = new RoutedEventArgs(LoadedEvent);
- eventArgs.Source = null;
- RaiseEvent(eventArgs);
+ RaiseEvent(e);
}
///
/// Invoked just before the event.
///
- protected virtual void OnUnloaded()
+ /// The event args.
+ protected virtual void OnUnloaded(RoutedEventArgs e)
{
- var eventArgs = new RoutedEventArgs(UnloadedEvent);
- eventArgs.Source = null;
- RaiseEvent(eventArgs);
+ RaiseEvent(e);
}
///
diff --git a/src/Avalonia.Controls/ToggleSwitch.cs b/src/Avalonia.Controls/ToggleSwitch.cs
index 48b068d324..dc6b946381 100644
--- a/src/Avalonia.Controls/ToggleSwitch.cs
+++ b/src/Avalonia.Controls/ToggleSwitch.cs
@@ -3,6 +3,7 @@ using Avalonia.Controls.Metadata;
using Avalonia.Controls.Presenters;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Templates;
+using Avalonia.Interactivity;
using Avalonia.LogicalTree;
namespace Avalonia.Controls
@@ -200,9 +201,10 @@ namespace Avalonia.Controls
}
}
- protected override void OnLoaded()
+ ///
+ protected override void OnLoaded(RoutedEventArgs e)
{
- base.OnLoaded();
+ base.OnLoaded(e);
UpdateKnobTransitions();
}