feat: Theme toggler
This commit is contained in:
@@ -20,4 +20,22 @@ internal static class EventHelper
|
||||
if(button is not null) button.Click -= handler;
|
||||
}
|
||||
}
|
||||
|
||||
public static void RegisterEvent<TArgs>(RoutedEvent<TArgs> routedEvent, EventHandler<TArgs> handler, params Button?[] controls)
|
||||
where TArgs : RoutedEventArgs
|
||||
{
|
||||
foreach (var control in controls)
|
||||
{
|
||||
control?.AddHandler(routedEvent, handler);
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnregisterEvent<TArgs>(RoutedEvent<TArgs> routedEvent, EventHandler<TArgs> handler, params Button?[] controls)
|
||||
where TArgs : RoutedEventArgs
|
||||
{
|
||||
foreach (var control in controls)
|
||||
{
|
||||
control?.RemoveHandler(routedEvent, handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
14
src/Ursa/Common/PropertyHelper.cs
Normal file
14
src/Ursa/Common/PropertyHelper.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Avalonia;
|
||||
|
||||
namespace Ursa.Common;
|
||||
|
||||
public static class PropertyHelper
|
||||
{
|
||||
public static void SetValue<TValue>(AvaloniaProperty<TValue> property, TValue value, params AvaloniaObject?[] elements)
|
||||
{
|
||||
foreach (var element in elements)
|
||||
{
|
||||
element?.SetValue(property, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user