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


namespace ContextMenus
{
	public partial class MainPage : UserControl
	{
		public MainPage()
		{
			InitializeComponent();

			// Uncomment to enable Hierarchy
			//this.clubsGrid.TableDefinition.ChildTableDefinitions.Add(
			//    new GridViewTableDefinition
			//    {
			//        Relation = new PropertyRelation("Players")
			//    });
		}

		private void Button1_Click(object sender, RoutedEventArgs e)
		{

		}

		private void Button2_Click(object sender, RoutedEventArgs e)
		{

		}

		private void clubsGrid_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
		{

			if (!(e.Row is GridViewHeaderRow) && !(e.Row is GridViewNewRow))
			{
				RadContextMenu rowContextMenu = new RadContextMenu(); // create menu				

				// create menu items
				rowContextMenu.Items.Add(new RadMenuItem() { Header = "ParentGrid" });
				rowContextMenu.Items.Add(new RadMenuItem() { Header = "Item1.1"});
				rowContextMenu.Items.Add(new RadMenuItem() { Header = "Item1.2"});

				RadContextMenu.SetContextMenu(e.Row, rowContextMenu);
			}
		}

		private void playersGrid_RowLoaded(object sender, RowLoadedEventArgs e)
		{
			if (!(e.Row is GridViewHeaderRow) && !(e.Row is GridViewNewRow))
			{
				RadContextMenu rowContextMenu = new RadContextMenu(); // create menu				

				// create menu items
				rowContextMenu.Items.Add(new RadMenuItem() { Header = "Child Grid" });
				rowContextMenu.Items.Add(new RadMenuItem() { Header = "Item2.1"});
				rowContextMenu.Items.Add(new RadMenuItem() { Header = "Item2.2"});

				RadContextMenu.SetContextMenu(e.Row, rowContextMenu);
			}
		}
	}
}
