예제 #1
0
        protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
        {
            var mouseTarget        = InputHitTest(Mouse.GetPosition(this)) as DependencyObject;
            var targetListViewItem = UIHelpers.FindVisualAncestorByType <ListBoxItem>(mouseTarget);

            if (targetListViewItem != null)
            {
                e.Handled = true;
                return;
            }
            base.OnMouseRightButtonDown(e);
        }
예제 #2
0
        protected override void OnContextMenuOpening(ContextMenuEventArgs e)
        {
            var mouseTarget        = InputHitTest(Mouse.GetPosition(this)) as DependencyObject;
            var targetListViewItem = UIHelpers.FindVisualAncestorByType <ListBoxItem>(mouseTarget);

            if (targetListViewItem == null)
            {
                e.Handled = true;
                return;
            }

            var tradeRoute = targetListViewItem.DataContext as TradeRoute;

            if (tradeRoute == null)
            {
                e.Handled = true;
                return;
            }

            PopulateTradeRouteMenu(tradeRoute);

            base.OnContextMenuOpening(e);
        }