public interface IRunicMenuCheckedSource A Window's root ViewModel that supplies the check marks of the menu bar's check and radio items while its Window is the key window.
Remarks
An item declared with a non-null DesktopMenuItem.IsChecked is a check or radio item. The host asks IRunicMenuCheckedSource.IsMenuItemChecked for each of them in the ViewModel's model turn when the Window opens, when the menu bar changes, and in the model turn after the root ViewModel raises INotifyPropertyChanged.PropertyChanged for any property (once for several in a turn). Only the root ViewModel is followed: when an answer depends on a child ViewModel or other state, call RunicMenu.Refresh with the root ViewModel after it changed. Answer from the ViewModel's own state: public sealed partial class EditorViewModel : ObservableObject, IRunicMenuCommandSource, IRunicMenuCheckedSource
{
[ObservableProperty] private bool _wordWrap;
[ObservableProperty] private int _zoom = 100;
public bool? IsMenuItemChecked(string commandId, string? commandParameter) => commandId switch
{
"view.wrap" => WordWrap,
"view.zoom" => commandParameter == Zoom.ToString(CultureInfo.InvariantCulture), // a radio group
_ => null,
};
} The menu bar then shows the answers natively, in the page's own menu bar and in a desktop's global menu, and follows the key window: each Window's root ViewModel answers for its own Window. Each item of a radio group is asked on its own, so answer true for one of them. null leaves the item to the application's command target and then to its declared state; an answer that throws is logged as the menu command failure and counts as null. Commands that change the state are those of IRunicMenuCommandSource; a ViewModel may implement this interface without it, and its items are then run by the application's commands.
Methods
IsMenuItemChecked
bool? IsMenuItemChecked(string commandId, string? commandParameter) Gets whether a check or radio item shows its check mark, or null to keep the declaration.
Parameters
commandIdThe menu item's command id.
commandParameterThe menu item's command parameter,
nullfor none.