Home > other >  WPF
WPF

Time:09-30

In usercontrol into the multiple button, can be in load his main interface to realize each button click event, each family

CodePudding user response:

Can be added on top of the container, by routing event to click on the button

CodePudding user response:

reference 1st floor lindexi_gd response:
can be added on top of the container, by routing event got button click

Hello, thank you for your answer, beginners c # and WPF, I wrote a method and invoke,
Public void bindEvent ()
{
If (BTNS!=null)//BTNS are a collection of all the previously defined button
{
Foreach (Button BTN BTNS in)
BTN. Click +=new RoutedEventHandler (btnA1_Click);//EventHandler
BTN. KeyDown +=new KeyEventHandler (btnA1_KeyDown);
}
}
}
But I don't know is which routing method is handling does not include the data of the events, on the winform and usage are different in the WPF

CodePudding user response:

refer to the second floor qq_44960754 response:
Quote: refer to 1st floor lindexi_gd response:

Can be added on top of the container, by routing event got button click

Hello, thank you for your answer, beginners c # and WPF, I wrote a method and invoke,
Public void bindEvent ()
{
If (BTNS!=null)//BTNS are a collection of all the previously defined button
{
Foreach (Button BTN BTNS in)
BTN. Click +=new RoutedEventHandler (btnA1_Click);//EventHandler
BTN. KeyDown +=new KeyEventHandler (btnA1_KeyDown);
}
}
}
But I don't know is which routing method is handling does not include the data of the events, on the winform and usage are different in the WPF


Writing code is a bit strange oh, please use the first method the first character capitalized at the beginning, well, problem please look at the code rules [dotnet design specification _lindexi_lindexi_gd - CSDN blog] (https://blog.csdn.net/lindexi_gd/category_9272066.html)

The second event to the button, please use +=add method can, you can ignore the new written RoutedEventHandler

But which routing method is handling does not include the data of the events that you now every btnA1_Click method is invoked is routing content of events, this need according to your business to

I think the knife kung fu cannot little, recommend you my blog how to debug the code/dotnet code debug method (https://blog.lindexi.com/post/dotnet-%E4%BB%A3%E7%A0%81%E8%B0%83%E8%AF%95%E6%96%B9%E6%B3%95.html)

CodePudding user response:

reference lindexi_gd reply: 3/f
Quote: refer to the second floor qq_44960754 response:

Quote: refer to 1st floor lindexi_gd response:

Can be added on top of the container, by routing event got button click

Hello, thank you for your answer, beginners c # and WPF, I wrote a method and invoke,
Public void bindEvent ()
{
If (BTNS!=null)//BTNS are a collection of all the previously defined button
{
Foreach (Button BTN BTNS in)
BTN. Click +=new RoutedEventHandler (btnA1_Click);//EventHandler
BTN. KeyDown +=new KeyEventHandler (btnA1_KeyDown);
}
}
}
But I don't know is which routing method is handling does not include the data of the events, on the winform and usage are different in the WPF


Writing code is a bit strange oh, please use the first method the first character capitalized at the beginning, well, problem please look at the code rules [dotnet design specification _lindexi_lindexi_gd - CSDN blog] (https://blog.csdn.net/lindexi_gd/category_9272066.html)

The second event to the button, please use +=add method can, you can ignore the new written RoutedEventHandler

But which routing method is handling does not include the data of the events that you now every btnA1_Click method is invoked is routing content of events, this need according to your business to

I think knife kung fu cannot little, give you recommend my blog how to debug the code/dotnet code debug method (https://blog.lindexi.com/post/dotnet-%E4%BB%A3%E7%A0%81%E8%B0%83%E8%AF%95%E6%96%B9%E6%B3%95.html)

Ok, thank you teacher