# Prevent Dialogs from Opening

## How to hide a RadScheduleView dialog

In order to prevent a specific dialog from appearing , the ShowDialog event of the **RadScheduleView** should be cancelled. The event args contain a property called **DialogViewModel** which can be used to determine which dialog is going to be opened.

For example the view model for the **EditAppointmentDialog** is **AppointmentDialogViewModel**. The following code snippet shows how it can be cancelled:

```XAML
<telerik:RadScheduleView AppointmentsSource="{Binding Appointments}" ShowDialog="RadScheduleView_ShowDialog">
</telerik:RadScheduleView>
```

```C#
private void RadScheduleView_ShowDialog(object sender, ShowDialogEventArgs e)
{
    if (e.DialogViewModel is AppointmentDialogViewModel)
        e.Cancel = true;
}
```

```VB.NET
	Private Sub RadScheduleView_ShowDialog(sender As System.Object, e As ShowDialogEventArgs)
	    If TypeOf e.DialogViewModel Is AppointmentDialogViewModel Then
	       e.Cancel = True
	    End If
	End Sub
```

> To learn more about **RadScheduleView** events, check [here](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/events/overview).

## How to skip ConfirmDeleteDialog

In this case **DefaultDialogResult** property of the event args should be set in order to stimulate pressing OK/Cancel in the dialog. If **DefaultDialogResult** is set to “true”, the appointment will be directly deleted:

```C#
private void RadScheduleView_ShowDialog(object sender, ShowDialogEventArgs e)
{
    if (e.DialogViewModel is ConfirmDialogViewModel)
    {
        e.DefaultDialogResult = true;
        e.Cancel = true;
    }
}
```

```VB.NET
	Private Sub RadScheduleView_ShowDialog(sender As System.Object, e As ShowDialogEventArgs)
	    If TypeOf e.DialogViewModel Is ConfirmDialogViewModel Then
	        e.DefaultDialogResult = True
	        e.Cancel = True
	    End If
	End Sub
```

## How to preselect  a certain option in RecurrenceChoiceDialog

By default  “Open/Delete the occurrence” option is selected in RecurrenceChoiceDialog.  This can be changed in ShowDialog event by setting **IsSeriesModeSelected** property of the RecurrenceChoiceDialogViewModel:

```C#
private void RadScheduleView_ShowDialog(object sender, ShowDialogEventArgs e)
{
    var dialogViewModel = e.DialogViewModel as RecurrenceChoiceDialogViewModel;
    if (dialogViewModel != null)
    {
        dialogViewModel.IsSeriesModeSelected = true;
    }
}
```

```VB.NET
	Private Sub RadScheduleView_ShowDialog(sender As System.Object, e As ShowDialogEventArgs)
	   Dim dialogViewModel = TryCast(e.DialogViewModel, RecurrenceChoiceDialogViewModel)
	   If dialogViewModel IsNot Nothing Then
	       dialogViewModel.IsSeriesModeSelected = True
	   End If
	End Sub
```

> tip Check [here](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/custom-dialogs) for more information about RadScheduleView dialogs.
