WPF button click in C# code
问题 I have an array of button which is dynamically generated at run time. I have the function for button click in my code, but I can't find a way to set the button's click name in code. So, what is the code equivalent for XAML: <Button x:Name="btn1" Click="btn1_Click"> Or, what should I place for "????" in the following Code: Button btn = new Button() btn.Name = "btn1"; btn.???? = "btn1_Click"; 回答1: Button btn = new Button(); btn.Name = "btn1"; btn.Click += btn1_Click; private void btn1_Click