using System; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; public class MainClass : Window { [STAThread] public static void Main() { Application app = new Application(); app.Run(new MainClass()); } public MainClass() { Button btn = new Button(); btn.Content = "_Click me"; btn.Click += ButtonOnClick; Content = btn; } void ButtonOnClick(object sender, RoutedEventArgs args) { MessageBox.Show("asdf",Title); } }
24.4.Button Action | ||||
24.4.1. | Button Click event handler | |||
24.4.2. | Use Button IsMouseOver Event tro Trigger an Action | |||
24.4.3. | implementation of button's Click event handler in Xaml | |||
24.4.4. | Button mouse down event | |||
24.4.5. | Button mouse down preview event | |||
24.4.6. | Button PreviewMouseDown action and MouseDown action | |||
24.4.7. | Button click action | |||
24.4.8. | Dynamically add Button to a Grid and add Action listener | |||
24.4.9. | Do event based on button name | |||
24.4.10. | Button PreviewMouseLeftButtonDown action and MouseLeftButtonDown action | |||
24.4.11. | Check if mouse left or right button clicked | |||
24.4.12. | Get mouse clicked button with MouseButtonEventArgs.ChangedButton | |||
24.4.13. | Adding click handler for Button | |||
24.4.14. | Add application command to a Button, and listen to application paste command | |||
24.4.15. | Button mouse enter and leave event | |||
24.4.16. | Button click event listener | |||
24.4.17. | Anonymous delegate as Button Action |