You only need to add common shortcuts in the background.
CodeAs follows:
Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;
Using system. windows;
Using system. Windows. controls;
Using system. Windows. Data;
Using system. Windows. documents;
Using system. Windows. input;
Using system. Windows. Media;
Using system. Windows. Media. imaging;
Using system. Windows. shapes;
namespace wpfdatagrid
{< br> ///
/// interaction logic for window2.xaml
///
Public partial class window2: window
{< br> Public window2 ()
{< br> initializecomponent ();
This. loaded + = new routedeventhandler (window2_loaded);
}
Void window2_loaded (Object sender, routedeventargs E)
{
This. previewkeydown + = new keyeventhandler (window2_previewkeydown );
Button1.click + = new routedeventhandler (button#click );
}
Void button#click (Object sender, routedeventargs E)
{
Mainwindow main = new mainwindow ();
Main. showdialog ();
}
void window2_previewkeydown (Object sender, keyeventargs e)
{< br> If (E. key = key. f1)
{< br> button#click (this, null);
}< BR >}