0
嗨我想在Windows 8中使用彈出窗口創建一個上下文菜單。上的按鈕右擊我打電話下面的函數在Windows 8中使用彈出窗口的上下文菜單
private async void UIElement_OnRightTapped(object sender, RightTappedRoutedEventArgs e)
{
PopupMenu popUpMenu = new PopupMenu();
popUpMenu.Commands.Add(new UICommand("File"));
Rect rect = GetRect(sender);
var result= await popUpMenu.ShowForSelectionAsync(rect, Placement.Right);
}
雖然認定中的GetRect方法如下: -
private Rect GetRect(object sender)
{
FrameworkElement element = sender as FrameworkElement;
GeneralTransform elementTransform = element.TransformToVisual(null);
Point point = elementTransform.TransformPoint(new Point());
Size size = new Size(element.ActualWidth, element.ActualHeight);
Rect rect = new Rect(point, size);
return rect;
}
雖然與getRect正在返回正確的值,但仍然我得到的結果爲空。
請幫忙
我不知道爲什麼當我運行它沒有調試,這工作正常 – 2013-03-06 18:18:52