开发者

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);
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜