Browse Source

Update sample for macOS checked menu item

pull/3762/head
Michael Babienco 7 years ago
committed by Dan Walmsley
parent
commit
f8756416be
  1. 9
      samples/ControlCatalog/MainWindow.xaml
  2. 15
      samples/ControlCatalog/ViewModels/MainWindowViewModel.cs

9
samples/ControlCatalog/MainWindow.xaml

@ -36,6 +36,15 @@
</NativeMenu>
</NativeMenuItem.Menu>
</NativeMenuItem>
<NativeMenuItem Header="Options">
<NativeMenuItem.Menu>
<NativeMenu>
<NativeMenuItem Header="Check Me Out"
Command="{Binding ToggleMenuItemCheckedCommand}"
IsChecked="{Binding IsMenuItemChecked}" />
</NativeMenu>
</NativeMenuItem.Menu>
</NativeMenuItem>
</NativeMenu>
</NativeMenu.Menu>

15
samples/ControlCatalog/ViewModels/MainWindowViewModel.cs

@ -10,6 +10,8 @@ namespace ControlCatalog.ViewModels
{
private IManagedNotificationManager _notificationManager;
private bool _isMenuItemChecked = true;
public MainWindowViewModel(IManagedNotificationManager notificationManager)
{
_notificationManager = notificationManager;
@ -42,6 +44,11 @@ namespace ControlCatalog.ViewModels
{
(App.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime).Shutdown();
});
ToggleMenuItemCheckedCommand = ReactiveCommand.Create(() =>
{
IsMenuItemChecked = !IsMenuItemChecked;
});
}
public IManagedNotificationManager NotificationManager
@ -50,6 +57,12 @@ namespace ControlCatalog.ViewModels
set { this.RaiseAndSetIfChanged(ref _notificationManager, value); }
}
public bool IsMenuItemChecked
{
get { return _isMenuItemChecked; }
set { this.RaiseAndSetIfChanged(ref _isMenuItemChecked, value); }
}
public ReactiveCommand<Unit, Unit> ShowCustomManagedNotificationCommand { get; }
public ReactiveCommand<Unit, Unit> ShowManagedNotificationCommand { get; }
@ -59,5 +72,7 @@ namespace ControlCatalog.ViewModels
public ReactiveCommand<Unit, Unit> AboutCommand { get; }
public ReactiveCommand<Unit, Unit> ExitCommand { get; }
public ReactiveCommand<Unit, Unit> ToggleMenuItemCheckedCommand { get; }
}
}

Loading…
Cancel
Save