Nu fungerar RoundRunningView med minimal codeBehind

This commit is contained in:
2025-10-22 10:42:39 +02:00
parent ecd3e90dbf
commit 26ff51169f
13 changed files with 374 additions and 116 deletions

View File

@ -0,0 +1,35 @@
using System.Windows.Input;
namespace GreadyPoang.Common;
public class LoadedBehavior
{
public static readonly BindableProperty CommandProperty =
BindableProperty.CreateAttached(
"Command",
typeof(ICommand),
typeof(LoadedBehavior),
null,
propertyChanged: OnCommandChanged);
public static ICommand GetCommand(BindableObject view) =>
(ICommand)view.GetValue(CommandProperty);
public static void SetCommand(BindableObject view, ICommand value) =>
view.SetValue(CommandProperty, value);
private static void OnCommandChanged(BindableObject bindable, object oldValue, object newValue)
{
if (bindable is VisualElement element && newValue is ICommand command)
{
element.Loaded += (s, e) =>
{
if (command.CanExecute(null))
{
command.Execute(null);
}
};
}
}
}