如何将GotFocus值复制到新的Combobox? .NET wpf

时间:2017-10-04 09:39:08

标签: c# .net wpf events combobox

在XAML文件中,我有这样的ComboBox:

<ComboBox Name="please" GotFocus="JutstDoIt">
    <!-- some ComboBoxItems -->
</ComboBox>

在C#文件中我想从&#34复制GotFocus值;请&#34;到新的ComboBox

//ninja code
ComboBox powerranger= new ComboBox();
powerranger.Name = "iwillbeaninja";
//other not important ninja code
powerranger.GotFocus = please.GotFocus; //It's not working!!!! :( 
//more ninja code

我知道......这是事件,而不是财产。

1 个答案:

答案 0 :(得分:0)

好!我的senpai给了我一个答案!

    powerranger.GotFocus += new RoutedEventHandler(NameOfFunction);

很好!