Everyone wants to send a key,
but
No one wants to use Windows.Forms
Use this: (Replace ESC with your key and use where you need it, obviously)
var MAIN_WINDOW = System.Windows.Window.GetWindow (ChartControl); // Assuming ChartControl is a reference to the chart panel or control
if (MAIN_WINDOW != null)
{
MAIN_WINDOW.InputBindings.Add (new KeyBinding (ApplicationCommands.Close, new KeyGesture (Key.Escape)));
try
{
MAIN_WINDOW.CommandBindings[0].Command.Execute (null);
}
catch (Exception ex)
{
// Handle any exceptions
Console.WriteLine (ex.Message);
}
MAIN_WINDOW.InputBindings.Clear ();
}
✌

Comment