2012-08-10 104 views
0

在Windows 8 Metro應用程序中,我有一個組合框,每次從列表中選擇其他東西時我都想調用一個方法。沒有看到Combobox SelectionChanged事件?

我有我的方法,並與ValueChanged =「MyMethod」一個滑塊,它工作正常。

然而,當我嘗試用組合框:

<ComboBox x:Name="Mentality" SelectedValue="Item1" SelectionChanged="MyMethod" > 
       <x:String>Item1</x:String> 
       <x:String>Item2</x:String> 
       <x:String>Item3/x:String> 

我有這樣的錯誤:

No overload for 'MyMethod' matches delegate Windows.UI.Xaml.Controls.SelectionChangedEventHandler'

+1

是公共的MyMethod和你傳遞的事件參數以及方法簽名的來源說法? – JonH 2012-08-10 14:13:59

+0

顯示MyMethod()的方法聲明 – MethodMan 2012-08-10 14:36:56

回答

2

ValueChangedSelectionChanged有不同的簽名。兩個都不能使用相同的處理程序。

要連接到SelectionChanged,你需要這樣的方法:

void MyMethod(object sender, SelectionChangedEventArgs e) 
相關問題