I have software that uses several XAML windows for different instances: for example, to export some information, I created secondary XAML windows with a different format than the parent program. They work great.
My problem is that if I use my software without calling any of these additional XAML windows, shortcuts work very well. But as soon as I call this new XAML window, the shortcuts no longer work. I need to restart the program so that they return.
Any clue to this behavior? Also, I have not yet been able to create shortcuts like CTRL + Letter. I saw a lot of codes, it seems pretty straight forward, but they just don't work ...
code
private void Window_KeyDown(object sender, KeyEventArgs e) { Key key = e.Key; if ((key == Key.Left) && previousButton.IsEnabled) button_PreviewMouseDown(previousButton, null); else if ((key == Key.Right) && nextButton.IsEnabled) button_PreviewMouseDown(nextButton, null); //New Label else if (key == Key.L) //else if (key == Key.LeftAlt && e.Key.ToString() == "L") NewLabel_Click(sender, e); // Begin Event else if (key == Key.B) BeginEvent_Click(sender, e); // End Event else if (key == Key.E) EndEvent_Click(sender, e); // Delete Label else if (key == Key.K) DeleteLabel_Click(sender, e); else if (key == Key.R) // Delete Event DeleteEvent_Click(sender, e); // Edit Label else if (key == Key.I) EditLabel_Click(sender, e); // Edit Event else if (key == Key.F) EditEvent_Click(sender, e); }
EDIT 1
I found out that as soon as I call up a popup with C #, just saying โEvent Created OKโ, the shortcuts come to life again!
MessageBox.Show("Event Created");
Any idea why this might happen?
source share