2017-10-04 23 views
-2

在XAML文件中我的ComboBox這樣的:如何將GotFocus的價值複製到新的Combobox中? .NET WPF

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

在C#中的文件我想的GotFocus值從 「請」 複製到新的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

好吧!我的senpai給了我一個答案!

powerranger.GotFocus += new RoutedEventHandler(NameOfFunction); 

這很好!

相關問題