AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
26.12k stars 2.26k forks source link

Label fails to underline keyboard shortcut key until Alt key is pressed #9720

Open AArnott opened 1 year ago

AArnott commented 1 year ago

Describe the bug

Windows used to always underline keyboard shortcut keys. Recent version have that behavior off by default, but it can be activated as described below. Most apps honor this setting, but Avalonia Labels do not.

To Reproduce

Configure Windows to always underline keyboard shortcut keys: image

Given a window with this xaml:

<Window xmlns="https://github.com/avaloniaui"
        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"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="MyApp.MainWindow"
        Title="MyApp">
    <StackPanel>
        <Label Content="Select _textbox" Target="{Binding #txtbox}" />
        <TextBox Name="txtbox" />
    </StackPanel>
</Window>

Run the program

Expected behavior

The "t" in "Select textbox" should be underlined immediately.

Screenshots

Without the alt key pressed: image

With the alt key pressed: image

Desktop (please complete the following information):

grokys commented 1 year ago

Yeah I'm afraid we don't yet have an API to surface that setting inside of Avalonia.

maxkatz6 commented 1 year ago

At some point we might need to have some alternative of SystemParameters from WPF. Unfortunately, most of the platforms don't have as many parameters available for apps, like Windows does.

AArnott commented 1 year ago

I wonder if some use of Microsoft.Extensions.Configuration might be useful to back the SystemParameters class. On Windows, it could include a data source that is the OS itself. For OSs that don't define as many of these parameters, end users or app developers could still control these settings by way of an appsettings.json or user settings.json file.