in

Why InputGestureText is greyed out?


I’m pretty new to WPF and I’m trying to use the InputGestureText property to show a hotkey for a menu item. Unfortunately, I don’t understand why the text is greyed out. The item is still clickable though.

Below are my code. I’m using .NET 6 with Visual Studio 2022.

MainWindow.xaml:

<Window x:Class="WpfApp1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:WpfApp1"
    mc:Ignorable="d"
    Title="MainWindow" Height="100" Width="200"
    d:DataContext="{d:DesignInstance Type=local:MainWindow}">
    <Grid>
        <Menu VerticalAlignment="Top">
            <MenuItem Header="Menu">
                <MenuItem Header="Item" InputGestureText="Ctrl+A" Command="{Binding MenuCommand}"/>
            </MenuItem>
        </Menu>
    </Grid>
</Window>

MainWindow.xaml.cs:

namespace WpfApp1 {
    public partial class MainWindow : Window {
        public MenuCommand MenuCommand { get; set; } = new MenuCommand();
        public MainWindow() {
            InitializeComponent();
            DataContext = this;
        }
    }
    public class MenuCommand : ICommand {
        public event EventHandler? CanExecuteChanged;
        public bool CanExecute(object? parameter) {
            return true;
        }
        public void Execute(object? parameter) {
            MessageBox.Show("Item is pressed.");
        }
    }
}



Source: https://stackoverflow.com/questions/70534625/why-inputgesturetext-is-greyed-out

HOSTNOC: Atom Dedis Starting at $14.69/month!

An e-commerce UI concept in Flutter for Android and iOS