连接SelectionChanged事件的comboBox在Silverlight 4中打破绑定

时间:2012-05-15 05:08:40

标签: c# binding silverlight-4.0

我将ComboBox的“SelectedValue”绑定到自定义类。

...
<ComboBox SelectedValue="{Binding camera,Mode=TwoWay}" SelectedValuePath="Content">     
<ComboBoxItem Content="Canon EOS 7D" />                                  
</ComboBox>
...

在我尝试将ComboBox的“SelectionChanged”事件连接到一个不属于自定义类的函数之前,它工作正常:

...
<ComboBox SelectedValue="{Binding camera,Mode=TwoWay}" SelectedValuePath="Content" SelectionChanged="event_handler">     
<ComboBoxItem Content="Canon EOS 7D" />                                  
</ComboBox>
...

上面有这个xaml我得到了“无法分配给属性'System.Windows.Controls.Primitives.Selector.SelectionChanged'。”异常,其中设置了dataform的数据源:

dataFormEditCurrent.CurrentItem = tmpPhoto;

我做错了什么,如何解决这个问题?谢谢!

0 个答案:

没有答案