diff --git a/samples/IntegrationTestApp/App.axaml b/samples/IntegrationTestApp/App.axaml
index 7079074d64..f23ce53dbe 100644
--- a/samples/IntegrationTestApp/App.axaml
+++ b/samples/IntegrationTestApp/App.axaml
@@ -1,13 +1,21 @@
+ xmlns:self="using:IntegrationTestApp"
+ x:Class="IntegrationTestApp.App"
+ x:DataType="self:App"
+ RequestedThemeVariant="Default">
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/IntegrationTestApp/App.axaml.cs b/samples/IntegrationTestApp/App.axaml.cs
index 022931366d..59f1185e17 100644
--- a/samples/IntegrationTestApp/App.axaml.cs
+++ b/samples/IntegrationTestApp/App.axaml.cs
@@ -1,11 +1,25 @@
+using System.Windows.Input;
+
using Avalonia;
+using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
+using MiniMvvm;
namespace IntegrationTestApp
{
public class App : Application
{
+ public App()
+ {
+ ShowWindowCommand = MiniCommand.Create(() =>
+ {
+ var window = new Window() { Title = "TrayIcon demo window" };
+ window.Show();
+ });
+ DataContext = this;
+ }
+
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
@@ -20,5 +34,7 @@ namespace IntegrationTestApp
base.OnFrameworkInitializationCompleted();
}
+
+ public ICommand ShowWindowCommand { get; }
}
}
diff --git a/samples/IntegrationTestApp/IntegrationTestApp.csproj b/samples/IntegrationTestApp/IntegrationTestApp.csproj
index 587cc98d32..e1bfd6e7b1 100644
--- a/samples/IntegrationTestApp/IntegrationTestApp.csproj
+++ b/samples/IntegrationTestApp/IntegrationTestApp.csproj
@@ -25,6 +25,7 @@
+
diff --git a/src/Avalonia.Controls/NativeMenuItem.cs b/src/Avalonia.Controls/NativeMenuItem.cs
index 5c7c4242b9..6c093ff1f6 100644
--- a/src/Avalonia.Controls/NativeMenuItem.cs
+++ b/src/Avalonia.Controls/NativeMenuItem.cs
@@ -5,6 +5,7 @@ using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Media.Imaging;
using Avalonia.Metadata;
+using Avalonia.Threading;
using Avalonia.Utilities;
namespace Avalonia.Controls
@@ -164,7 +165,10 @@ namespace Avalonia.Controls
void CanExecuteChanged()
{
- SetCurrentValue(IsEnabledProperty, Command?.CanExecute(CommandParameter) ?? true);
+ if (!Dispatcher.UIThread.CheckAccess())
+ Dispatcher.UIThread.Invoke(() => CanExecuteChanged());
+ else
+ SetCurrentValue(IsEnabledProperty, Command?.CanExecute(CommandParameter) ?? true);
}
public bool HasClickHandlers => Click != null;