Open
Description
openedon Sep 13, 2022
Describe the bug
I am trying to bind the GoBack
and GoForward
buttons (aka VK_BROWSER_BACK
and VK_BROWSER_FORWARD
) in an UWP project.
When using the GoBack
, GoForward
and possibly other similar keys on a KeyboardAccelerator in XAML a XamlParseException with the message of Failed to create a 'Windows.System.VirtualKey' from the text 'GoBack'.
is thrown. Furthermore if the accelerator is added in the code-behind, it does not work.
Steps to reproduce the bug
Create a new blank page UWP project.
<Grid>
<StackPanel>
<Button x:Name="GoBack" Content="Go Back" Click="GoBack_Click">
<Button.KeyboardAccelerators>
<KeyboardAccelerator Modifiers="Menu" Key="Left"/>
<KeyboardAccelerator Key="GoBack"/>
</Button.KeyboardAccelerators>
</Button>
</StackPanel>
</Grid>
Remove the "GoBack" accelerator to get past the exception.
namespace GoBack
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
GoBack.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = Windows.System.VirtualKey.GoBack });
GoBack.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = Windows.System.VirtualKey.Escape });
}
private async void GoBack_Click(object sender, RoutedEventArgs e)
{
var dialog = new MessageDialog("You clicked Go Back");
await dialog.ShowAsync();
}
}
}
Expected behavior
Escape and Alt+left works, but the back button does not. Expected all to work.
Screenshots
No response
NuGet package version
No response
Windows app type
- UWP
- Win32
Device form factor
Desktop
Windows version
Windows 11 (21H2): Build 22000
Additional context
Visual Studio 17.3.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment