在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
我知道......这是事件,而不是财产。
答案 0 :(得分:0)
好!我的senpai给了我一个答案!
powerranger.GotFocus += new RoutedEventHandler(NameOfFunction);
很好!