1 /// <summary>
2 /// 圖片鼠標右鍵
3 /// </summary>
4 /// <param name="sender"></param>
5 /// <param name="e"></param>
6 private void Image_slt_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
7 {
8 Point point = e.GetPosition(tree);
9 HitTestResult result = VisualTreeHelper.HitTest(tree, point);
10 if (result == null)
11 return;
12 ListBoxItem item = Utils.FindVisualParent<ListBoxItem>(result.VisualHit);
13 if (item == null)
14 return;
15 var vm_item = item.DataContext as ImageTreeControlImageModel;
16 if (vm_item == null)
17 return;
18 ContextMenu menu = new ContextMenu();
19 MenuItem mitem = new MenuItem();
20 mitem.Tag = vm_item;
21 mitem.Click += mItem_Click;
22 mitem.Header = "刪除";
23 menu.Items.Add(mitem);
24 menu.IsOpen = true;
25 }