I am writing a calculator for WPF . At the moment, pressing the buttons records data in the textbox , but I would like it to be pressed to the methods when pressing numbers on the keyboard, i.e. so stupid was the interception of buttons. I think it will be too redundant to do it through WinApi , isn’t there any such thing in WPF itself?
private void One_Click(object sender, RoutedEventArgs e) { if (totalled == true) { Display.Content = ""; totalled = false; } Display.Content += "1"; storageVariable += "1"; } private void Two_Click(object sender, RoutedEventArgs e) { if (totalled == true) { Display.Content = ""; totalled = false; } Display.Content += "2"; storageVariable += "2"; } private void Three_Click(object sender, RoutedEventArgs e) { if (totalled == true) { Display.Content = ""; totalled = false; } Display.Content += "3"; storageVariable += "3"; } private void Four_Click(object sender, RoutedEventArgs e) { if (totalled == true) { Display.Content = ""; totalled = false; } Display.Content += "4"; storageVariable += "4"; }