Hello,
Welcome to Microsoft Q&A,
For the testing, your code is correct and the issue does not reproduce in target version 1903. And above problem has fixed in 1903, please try to modify the target version and rebuild again.
Thanks
Nico Zhu
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I would like to add keyboard shortcuts to some buttons.
But for some reason the keyboard accelerator triggers the event twice.
When I just click the button with the mouse, it works as expected.
<MenuBar>
<MenuBarItem Title="File">
<MenuFlyoutItem Text="Open file..." Click="OnOpen" Icon="OpenFile">
<MenuFlyoutItem.KeyboardAccelerators>
<KeyboardAccelerator Key="O" Modifiers="Control"/>
</MenuFlyoutItem.KeyboardAccelerators>
</MenuFlyoutItem>
</MenuBarItem>
</MenuBar>
FileLoader.LoadFile here shows the FileOpenPicker:
private async void OnOpen(object sender, RoutedEventArgs e)
{
if (!Busy)
{
var loadedFile = await FileLoader.LoadFile(".txt", PickerLocationId.Desktop);
if(loadedFile ! null) //for some reason I can't type the doesn't equal operator on this forum without getting access denied errors.
{
await FileLoader.LoadTextFile(loadedFile);
}
}
}
The same problem is happening with a FileSavePicker elsewhere in my code.
How can I prevent this from happening?
Hello,
Welcome to Microsoft Q&A,
For the testing, your code is correct and the issue does not reproduce in target version 1903. And above problem has fixed in 1903, please try to modify the target version and rebuild again.
Thanks
Nico Zhu