2014-01-31 33 views
1

我想解決我的問題,使用addHandler方法,但我不知道如何正確設置其參數。 我的做法是:如何在代碼中將處理程序添加到ListBoxItem?

lbi.AddHandler(OnMouseLeftButtonUp, GoToEditDraft, true); 
public static void GoToEditDraft() 
    { 

    } 

我想有GoToEditDraft觸發一個ListBoxItem(LBI)當用戶點擊的方法。我明白我的數據類型錯誤,我沒有設置。如何正確設置? 謝謝!

回答

1

我想讓用戶點擊ListBoxItem(lbi)時觸發方法GoToEditDraft」。那麼怎麼樣這樣:

lbi.MouseLeftButtonUp += GoToEditDraft; 
private void GoToEditDraft(object sender, MouseButtonEventArgs mouseButtonEventArgs) 
{ 
    //TODO: put some logic here 
} 
+0

謝謝!這樣可行。我是Windows Phone的新手,而.net api有時會讓我感到恐慌。 – splash27

+0

哈哈..隨便問。在大多數情況下,.NET會以最簡單的方式公開API。也許以其他編程語言的不同風格(python可能?)的先前知識,使得以.NET方式進行思考看起來並不簡單 – har07

+0

是的,你是對的,我來自Python。 – splash27

相關問題