# Context Menu Owner

The **RadContextMenu** provides properties and methods for working with the UI element that opened it. You can access the owner, determine the mouse position, retrieve a clicked item from the event route, and restore focus to the owner after the menu closes.

## Access the Context Menu Owner

The `UIElement` property returns the element to which the **RadContextMenu** is attached. The `MousePosition` property returns the mouse position relative to the element that caused the menu to open.

**Access the Context Menu Owner and Mouse Position**

```C#
UIElement owner = this.radContextMenu.UIElement;
Point position = this.radContextMenu.MousePosition;
```

Use the owner and position information when a command needs to update the element that opened the menu or interpret the location of the click.

## Get the Clicked Element

When an element gets clicked and the **RadContextMenu** appears, you can use the `GetClickedElement<T>()` method to retrieve the first element of type `T` in the visual tree that is part of the route of the event that opened the menu.

For example, if you have a **RadTreeView** with a **RadContextMenu** attached, handle the **Opened** event to retrieve the **RadTreeViewItem** that was clicked.

**Get the Clicked Element in C#**

```C#
private void RadContextMenu_Opened(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    RadContextMenu contextMenu = (RadContextMenu)sender;
    RadTreeViewItem item = contextMenu.GetClickedElement<RadTreeViewItem>();
}
```

The returned `RadTreeViewItem` is the item that opened the context menu.

> tip More complex examples are available in [Using RadContextMenu within RadGridView](https://www.telerik.com/products/wpf/documentation/knowledge-base/kb-contextmenu-use-with-radgridview) and [Selecting the Clicked Item of a RadTreeView](https://www.telerik.com/products/wpf/documentation/knowledge-base/kb-contextmenu-select-clicked-item-radtreeview).

## Restore Focus to the Context Menu Owner

When opened, the **RadContextMenu** automatically receives focus. Set `RestoreFocusToTargetElement` to `True` to return focus to the element that opened the menu after it closes.

**Restore Focus to the Context Menu Owner**

```XAML
<telerik:RadContextMenu xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                        RestoreFocusToTargetElement="True" />
```

## See Also

* [Getting Started](https://www.telerik.com/products/wpf/documentation/controls/radcontextmenu/getting-started)

* [Setting the Opening Event](https://www.telerik.com/products/wpf/documentation/controls/radcontextmenu/opening-on-specific-event)

* [Using RadContextMenu within RadGridView](https://www.telerik.com/products/wpf/documentation/knowledge-base/kb-contextmenu-use-with-radgridview)

* [Selecting the Clicked Item of a RadTreeView](https://www.telerik.com/products/wpf/documentation/knowledge-base/kb-contextmenu-select-clicked-item-radtreeview)

* [Retrieve the Clicked Item When Opening a RadContextMenu](https://www.telerik.com/products/wpf/documentation/knowledge-base/kb-contextmenu-retrieve-the-clicked-element)
