Can I bind two methods to a WPF Control?
I have this combo box
<ComboBox Height="23"
SelectionChanged="comboBox1_SelectionChanged">
<ComboBoxItem Content="Opt1"/>
<ComboBoxItem Content="Opt2"/>
</ComboBox>
Basically what I need is to 开发者_如何转开发run two methods, the one already bound (combobox1_SelectionChanged) and an additional one I created. Is this possible?
I would probably just bind to 1 function and have that function call the common pieces of code.
Yes, but you can't do this declaratively. Use the +=
operator in C#.
MyComboBox.SelectionChanged += new SelectionChangedEventHandler(method1);
MyComboBox.SelectionChanged += new SelectionChangedEventHandler(method2);
...
精彩评论