# Events

This article lists the events of the RadCallout control when placed inside a Popup. Subscribing to the events of the control can be achieved through the **CalloutPopupService** class. The service exposes several methods to add/remove event handlers for the RadCallout control events.

> The following events are related only for the placement target element.

## Subscribe to RadCallout Events in XAML

You can subscribe to the placement target element events of the Popup holding the RadCallout, using the CalloutPopupService.

**Example 1: Add event handler to PopupOpening in XAML**

```XAML
<telerik:RadButton x:Name="myPlacementTargetElement" telerik:CalloutPopupService.PopupOpening="OnPopupOpening" Content="My Button"  />

```

```C#
public void SubscribeToPopupClosed()
{
    CalloutPopupService.AddPopupClosedHandler(myPlacementTargetElement, OnPopupClosed);
}
private void OnPopupClosed(object sender, RoutedEventArgs e)
{
}
```

## Subscribe to RadCallout Events in Code Behind

* **PopupOpening**: Occurs before the RadCallout is shown. Through the **CancelRoutedEventArgs**, you can access the following property:

  * **Cancel**: A boolean property that can be used to cancel the control from appearing.

  **Example 2: Add event handler to PopupOpening**

```XAML
<telerik:RadButton x:Name="myPlacementTargetElement" telerik:CalloutPopupService.PopupOpening="OnPopupOpening" Content="My Button"  />

```

```C#
public void SubscribeToPopupClosed()
{
    CalloutPopupService.AddPopupClosedHandler(myPlacementTargetElement, OnPopupClosed);
}
private void OnPopupClosed(object sender, RoutedEventArgs e)
{
}
```

* **PopupOpened**: Occurs after the RadCallout is shown.

  **Example 3: Add event handler to PopupOpened**

```XAML
<telerik:RadButton x:Name="myPlacementTargetElement" telerik:CalloutPopupService.PopupOpening="OnPopupOpening" Content="My Button"  />

```

```C#
public void SubscribeToPopupClosed()
{
    CalloutPopupService.AddPopupClosedHandler(myPlacementTargetElement, OnPopupClosed);
}
private void OnPopupClosed(object sender, RoutedEventArgs e)
{
}
```

* **PopupClosing**: Occurs before the RadCallout is closed. Through the **CancelRoutedEventArgs**, you can access the following property:

  * **Cancel**: A boolean property that can be used to cancel the RadCallout control from closing.

  **Example 4: Add event handler to PopupClosing**

```XAML
<telerik:RadButton x:Name="myPlacementTargetElement" telerik:CalloutPopupService.PopupOpening="OnPopupOpening" Content="My Button"  />

```

```C#
public void SubscribeToPopupClosed()
{
    CalloutPopupService.AddPopupClosedHandler(myPlacementTargetElement, OnPopupClosed);
}
private void OnPopupClosed(object sender, RoutedEventArgs e)
{
}
```

* **PopupClosed**: Occurs after the RadCallout is closed.

  **Example 5: Add event handler to PopupClosed**

```XAML
<telerik:RadButton x:Name="myPlacementTargetElement" telerik:CalloutPopupService.PopupOpening="OnPopupOpening" Content="My Button"  />

```

```C#
public void SubscribeToPopupClosed()
{
    CalloutPopupService.AddPopupClosedHandler(myPlacementTargetElement, OnPopupClosed);
}
private void OnPopupClosed(object sender, RoutedEventArgs e)
{
}
```

## Unsubscribe from RadCallout Events

The **CalloutPopupService** class expose several methods to remove the events handlers.

**Example 6: Remove event handlers**

```C#
public void RemoveSubscriptionToAllEvents()
{
    CalloutPopupService.RemovePopupOpeningHandler(myPlacementTargetElement, OnPopupOpening);
    CalloutPopupService.RemovePopupOpenedHandler(myPlacementTargetElement, OnPopupOpened);
    CalloutPopupService.RemovePopupClosingHandler(myPlacementTargetElement, OnPopupClosing);
    CalloutPopupService.RemovePopupClosedHandler(myPlacementTargetElement, OnPopupClosed);
}

```

## See Also

* [Getting Started](https://www.telerik.com/products/wpf/documentation/controls/radcallout/getting-started)
* [Key Properties](https://www.telerik.com/products/wpf/documentation/controls/radcallout/key-properties)
* [Animations](https://www.telerik.com/products/wpf/documentation/controls/radcallout/features/popupusage/animations)
