0
我在我的wpf網頁瀏覽器的書籤部分遇到了一些問題。我想能夠刪除已經存在的按鈕,但我似乎無法弄清楚如何檢測按鈕的內容,我右鍵單擊。 (爲了讓我的ContextMenu
顯示)。如何獲取右鍵點擊的上下文
My visual progress so far: http://puu.sh/6Dxat.png
添加上下文菜單的按鈕:
public void button_MouseRightButtonDown(object sender, MouseButtonEventArgs e)//add a context menu to buttons
{
Button button = sender as Button;
menu = new ContextMenu();
menu.Items.Add(new MenuItem() { Header = "Delete" });
button.ContextMenu = menu;
menu.Closed += button_DeleteButtonClicked;//find the right event
}
(我知道的情況下是錯誤的,但現在這並不重要。)
且事件:
private void button_DeleteButtonClicked(object sender, RoutedEventArgs e)//delete bookmark
{
//This is where I need help. I want the content (which is the URL) of the button
//right clicked onto, for example, show up in a messagebox. How to do?
}
非常感謝你!不知道「PlacementTarget」。非常感謝! – proah
不客氣proah。 :) –