Browse Source

Move dynamic name binding to static instead

pull/495/head
Ionite 9 months ago
parent
commit
7c746138e3
No known key found for this signature in database
  1. 2
      StabilityMatrix.Avalonia/Controls/AdvancedImageBoxView.axaml
  2. 15
      StabilityMatrix.Avalonia/Controls/AdvancedImageBoxView.axaml.cs

2
StabilityMatrix.Avalonia/Controls/AdvancedImageBoxView.axaml

@ -35,7 +35,7 @@
<controls:AdvancedImageBox.ContextFlyout>
<ui:FAMenuFlyout>
<ui:MenuFlyoutItem
x:Name="CopyMenuItem"
Command="{x:Static controls:AdvancedImageBoxView.FlyoutCopyCommand}"
CommandParameter="{Binding $parent[controls:AdvancedImageBox].Image}"
HotKey="Ctrl+C"
IconSource="Copy"

15
StabilityMatrix.Avalonia/Controls/AdvancedImageBoxView.axaml.cs

@ -1,9 +1,7 @@
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Media.Imaging;
using CommunityToolkit.Mvvm.Input;
using FluentAvalonia.UI.Controls;
using StabilityMatrix.Avalonia.Helpers;
using StabilityMatrix.Core.Helper;
@ -16,18 +14,9 @@ public partial class AdvancedImageBoxView : UserControl
InitializeComponent();
}
/// <inheritdoc />
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
base.OnApplyTemplate(e);
if (this.FindControl<MenuFlyoutItem>("CopyMenuItem") is { } copyMenuItem)
{
copyMenuItem.Command = new AsyncRelayCommand<Bitmap?>(FlyoutCopy);
}
}
public static AsyncRelayCommand<Bitmap?> FlyoutCopyCommand { get; } = new(FlyoutCopy);
private static async Task FlyoutCopy(Bitmap? image)
public static async Task FlyoutCopy(Bitmap? image)
{
if (image is null || !Compat.IsWindows)
return;

Loading…
Cancel
Save