# Events

`RadWebCam` exposes the following events, specific for the control.

## SnapshotTaken

The SnapshotTaken event fires when the "Take snapshot" button is pressed or when you call the `TakeSnapshot` method of RadWebCam.

The purpose of the event is to notify you that a snapshot has been taken and you need to take action, like saving it to a file.

The event arguments are of type `SnapshotTakenEventArgs` which expose a `Snapshot` property (of type BitmapSource).

**Subscribing to the SnapshotTaken event**

```C#
public MainWindow()
{
    InitializeComponent();
    this.radWebCam.SnapshotTaken += RadWebCam_SnapshotTaken;
}

private void RadWebCam_SnapshotTaken(object sender, SnapshotTakenEventArgs e)
{
    BitmapSource snapshot = e.Snapshot;
    // here you save the source to a file, in memory, or to show it in the UI
}
```

## CameraError

The `CameraError` event fires when one of the [expected camera errors](https://www.telerik.com/products/wpf/documentation/controls/radwebcam/features/errors#error-types) appears.

The event can be used to notify you about the corresponding error, or to replace the error message shown in the control.

The event arguments are of type `CameraErrorEventArgs` and they expose an `Error` property that contains information about the error. The Error property is of type `ErrorInfo` which gives you access to the message and state of the error via the `Message` and `ErrorState` properties.

**Subscribing to the CameraError event and replacing the no-camera error message**

```C#
public MainWindow()
{
    InitializeComponent();
    this.radWebCam.CameraError += RadWebCam_CameraError;
}

private void RadWebCam_CameraError(object sender, CameraErrorEventArgs e)
{
    if (e.Error.ErrorState == CameraErrorState.NoCamera)
    {
        e.Error.Message = "Cannot detect a camera device.";
    }
}
```

> caption Customized error message

![WPF RadWebCam Customized Error Message](https://www.telerik.com/products/wpf/documentation/assets/17a024991f7e92c8c6ea13f6b7b551e6/radwebcam-features-errors-3.png)

## RecordingStarted/Ended

The `RecordingStarted` event fires just before the camera control starts recording.

The event arguments are of type `RecordingStartedEventArgs` and can be used to cancel the recording start. To do this, set the `Cancel` property to True.

**Canceling the start recording action**

```C#
public MainWindow()
{
    InitializeComponent();
    this.radWebCam.RecordingStarted += RadWebCam_RecordingStarted;
}

private void RadWebCam_RecordingStarted(object sender, RecordingStartedEventArgs e)
{
    MessageBoxResult result = MessageBox.Show("The video will be recorded at " + this.webCam.RecordingFilePath + "\n\rDo you want to start recording?", "Start Video Recording", MessageBoxButton.YesNo, MessageBoxImage.Question);
    e.Cancel = result != MessageBoxResult.Yes;
}
```

The `RecordingEnded` event fires when the camera control stops recording.

> tip Read more about the video capturing in the [Recording Video](https://www.telerik.com/products/wpf/documentation/controls/radwebcam/features/recording-video) article.

## See Also

* [Getting Started](https://www.telerik.com/products/wpf/documentation/controls/radwebcam/getting-started)
* [Visual Structure](https://www.telerik.com/products/wpf/documentation/controls/radwebcam/visual-structure)
* [Snapshots](https://www.telerik.com/products/wpf/documentation/controls/radwebcam/features/snapshots)
* [Errors](https://www.telerik.com/products/wpf/documentation/controls/radwebcam/features/errors)
