Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MenuItem header is visually inconstant when using _ to indicate shortcut keys #589

Closed
TheJoeFin opened this issue Apr 13, 2023 · 2 comments
Assignees
Labels
bug Something isn't working locked-due-to-inactivity

Comments

@TheJoeFin
Copy link
Sponsor

Describe the bug

Within MenuItems you can add an underscore before the letter you want to use as the shortcut key. When using WPF UI adding underscores to the MenuItem makes the text a different style than menu items without an underscore.

To Reproduce

Add underscores to the header item in the MenuItem Header

Expected behavior

Consistent look across all MenuItems

Screenshots

    <ContextMenu x:Key="ContextMenuResource">
        <MenuItem Command="ApplicationCommands.Undo" />
        <MenuItem Command="ApplicationCommands.Redo" />
        <Separator />
        <MenuItem Command="ApplicationCommands.Cut" />
        <MenuItem Command="ApplicationCommands.Copy" />
        <MenuItem Command="ApplicationCommands.Paste" />
        <MenuItem
            Command="{x:Static local:EditTextWindow.OcrPasteCommand}"
            Header="OCR Paste"
            InputGestureText="Ctrl + Shift + V" />
        <Separator />
        <MenuItem
            Command="{x:Static local:EditTextWindow.IsolateSelectionCmd}"
            Header="Isolate Selected Text"
            InputGestureText="Ctrl + I" />
        <MenuItem
           Click="SelectLineMenuItem_Click"
           Header="Select Line"
            InputGestureText="Ctrl + L" />
        <MenuItem
           Command="{x:Static local:EditTextWindow.ToggleCaseCmd}"
           Header="Toggle Case"
           InputGestureText="Shift + F3" />
        <Separator />
        <MenuItem
            Click="MoveLineUpMenuItem_Click"
            Header="Move Selection _Up"
            InputGestureText="Alt + Up" />
        <MenuItem
            Click="MoveLineDownMenuItem_Click"
            Header="Move Selection _Down"
            InputGestureText="Alt + Down" />
    </ContextMenu>

image

OS version

Windows 11
Version 22H2 (OS Build 22621.1413)

.NET version

.NET 6

WPF-UI NuGet version

3.0.0.preview.1

Additional context

No response

@TheJoeFin TheJoeFin added the bug Something isn't working label Apr 13, 2023
@Chri-s
Copy link

Chri-s commented Mar 22, 2024

I have the same problem, it seems that the header with an underscore is displayed in AccessText instead of TextBlock.

I fixed this in my project by copying the style from the TextBlock (

<Style TargetType="{x:Type TextBlock}">
) and assigning it to AccessText in my project styles:

<!--  This is copied from the Wpf.UI TextBlock style.
        If a text contains an underscore ("_"), the TextBlock is replaced with AccessText.
        Wpf.Ui doesn't style the AccessText so has another look than text without underscore.
        This gives AccessText the same look as TextBlock. -->
<Style TargetType="{x:Type AccessText}">

    <!--<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}"/>-->

    <!--  The Display option causes a large aliasing effect  -->
    <!--<Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />-->
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="FontSize" Value="14" />
    <Setter Property="Margin" Value="0" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="OverridesDefaultStyle" Value="True" />
</Style>```

@pomianowski pomianowski self-assigned this Mar 22, 2024
@Chri-s
Copy link

Chri-s commented Mar 23, 2024

Wow, thanks for the fast fix!👍

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working locked-due-to-inactivity
Projects
None yet
Development

No branches or pull requests

3 participants