Dan Walmsley před 5 roky
rodič
revize
b17c69b4c1
1 změnil soubory, kde provedl 10 přidání a 1 odebrání
  1. 10 1
      samples/ControlCatalog/MainWindow.xaml.cs

+ 10 - 1
samples/ControlCatalog/MainWindow.xaml.cs

@@ -5,6 +5,7 @@ using Avalonia.Controls;
 using Avalonia.Controls.Notifications;
 using Avalonia.Input;
 using Avalonia.Markup.Xaml;
+using Avalonia.Threading;
 using ControlCatalog.ViewModels;
 
 namespace ControlCatalog
@@ -13,7 +14,7 @@ namespace ControlCatalog
     {
         private WindowNotificationManager _notificationArea;
         private NativeMenu _recentMenu;
-
+        private int seconds = 0;
         public MainWindow()
         {
             this.InitializeComponent();
@@ -29,6 +30,14 @@ namespace ControlCatalog
 
             DataContext = new MainWindowViewModel(_notificationArea);
             _recentMenu = ((NativeMenu.GetMenu(this).Items[0] as NativeMenuItem).Menu.Items[2] as NativeMenuItem).Menu;
+
+            var timer = new DispatcherTimer();
+            timer.Interval = TimeSpan.FromSeconds(1);
+            timer.Tick += (sender, e) =>
+            {                
+                ((NativeMenu.GetMenu(this).Items[0] as NativeMenuItem).Menu.Items[2] as NativeMenuItem).Header = $"Recent {seconds++}";
+            };
+            timer.Start();
             var mainMenu = this.FindControl<Menu>("MainMenu");
             mainMenu.AttachedToVisualTree += MenuAttached;
         }