using System.Windows;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.GridView;

namespace Commands2.Core
{
    public static class Utils
    {
        public static void GridContextMenuOpened(object sender, RoutedEventArgs e)
        {
            var menu = (RadContextMenu)sender;
            var row = menu.GetClickedElement<GridViewRow>();

            if (row == null)
            {
                menu.IsOpen = false;
                return;
            }

            row.IsSelected = row.IsCurrent = true;
            var cell = menu.GetClickedElement<GridViewCell>();
            if (cell != null)
            {
                cell.IsCurrent = true;
            }
        }
    }
}
