Hi Telerik team,
i created a custom appointment :
and here the content of editappointmenttemplate :
I would like to add validation to be sure than the user doesn't leave the combobox named "cmbWorks" empty ? how to proceed ?
I read this thread : http://www.telerik.com/community/forums/silverlight/scheduleview/ok-button-in-edit-appointment-dialog-window-is-disabled-for-new-appointment.aspx , this one http://www.telerik.com/community/forums/silverlight/scheduleview/how-to-validate-appointment-property-in-editappointmentdialog.aspx and also some others but it just added to my confusion :-( :
so, how to add this validation (don't leave empty the combobox) to have a custom error message displaying and the ok button disabled (just like it's the case if enddate < startdate) ?
thanks by advance for your answer, Regards,
Maxence
i created a custom appointment :
public class Imputation: Appointment
{
private Processus process;
public Processus Process
{
get
{
return this.Storage<
Imputation
>().process;
}
set
{
var storage = this.Storage<
Imputation
>();
if (storage.process != value)
{
storage.process = value;
this.OnPropertyChanged(() => this.Process);
}
}
}
private Projet project;
public Projet Project
{
get
{
return this.Storage<
Imputation
>().project;
}
set
{
var storage = this.Storage<
Imputation
>();
if (storage.project != value)
{
storage.project = value;
this.OnPropertyChanged(() => this.Project);
}
}
}
private Metier work;
public Metier Work
{
get
{
return this.Storage<
Imputation
>().work;
}
set
{
var storage = this.Storage<
Imputation
>();
if (storage.work != value)
{
storage.work = value;
this.OnPropertyChanged(() => this.Work);
}
}
}
private bool isMeeting;
public bool IsMeeting
{
get
{
return this.Storage<
Imputation
>().isMeeting;
}
set
{
var storage = this.Storage<
Imputation
>();
if (storage.isMeeting != value)
{
storage.isMeeting = value;
this.OnPropertyChanged(() => this.IsMeeting);
}
}
}
private bool isAdditionalHour;
public bool IsAdditionalHour
{
get
{
return this.Storage<
Imputation
>().isAdditionalHour;
}
set
{
var storage = this.Storage<
Imputation
>();
if (storage.isAdditionalHour != value)
{
storage.isAdditionalHour = value;
this.OnPropertyChanged(() => this.IsAdditionalHour);
}
}
}
public override IAppointment Copy()
{
var newImputation = new Imputation();
newImputation.CopyFrom(this);
return newImputation;
}
public override void CopyFrom(IAppointment other)
{
var imputation = other as Imputation;
if (imputation != null)
{
this.IsMeeting = imputation.IsMeeting;
this.IsAdditionalHour = imputation.IsMeeting;
this.Process = imputation.Process;
this.Project = imputation.Project;
this.Work = imputation.Work;
}
base.CopyFrom(other);
}
}
and here the content of editappointmenttemplate :
<
ControlTemplate
x:Key
=
"EditAppointmentTemplate"
TargetType
=
"telerik:SchedulerDialog"
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"*"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
</
Grid.RowDefinitions
>
<
telerik:RadToolBar
x:Name
=
"AppointmentToolbar"
GripVisibility
=
"Collapsed"
Margin
=
"-1 -1 -1 3"
Grid.Row
=
"0"
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
>
<
telerik:RadButton
x:Name
=
"EditRecurrenceButton"
Command
=
"telerik:RadScheduleViewCommands.EditRecurrenceRule"
Visibility
=
"{Binding CanEditParentAppointment, Converter={StaticResource InvertedBooleanToVisibilityConverter}}"
>
<
ToolTipService.ToolTip
>
<
ToolTip
telerik:LocalizationManager.ResourceKey
=
"EditRecurrence"
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
/>
</
ToolTipService.ToolTip
>
<
StackPanel
Margin
=
"2 0"
Orientation
=
"Horizontal"
>
<
Image
Margin
=
"2 0"
Source
=
"{StaticResource EditAppointmentTemplate_Recurrence}"
Stretch
=
"None"
/>
<
TextBlock
Foreground
=
"{StaticResource RadScheduleForeground}"
Margin
=
"4 0"
telerik:LocalizationManager.ResourceKey
=
"EditRecurrence"
/>
</
StackPanel
>
</
telerik:RadButton
>
<
telerik:RadButton
x:Name
=
"EditParentAppointmentButton"
Command
=
"telerik:RadScheduleViewCommands.EditParentAppointment"
IsEnabled
=
"{Binding IsReadOnly, Converter={StaticResource InvertedBooleanConverter}}"
Visibility
=
"{Binding CanEditParentAppointment, Converter={StaticResource BooleanToVisibilityConverter}}"
>
<
ToolTipService.ToolTip
>
<
TextBlock
telerik:LocalizationManager.ResourceKey
=
"EditParentAppointment"
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
/>
</
ToolTipService.ToolTip
>
<
TextBlock
Foreground
=
"{StaticResource RadScheduleForeground}"
Margin
=
"4 0"
telerik:LocalizationManager.ResourceKey
=
"EditParentAppointment"
/>
</
telerik:RadButton
>
</
telerik:RadToolBar
>
<
Border
x:Name
=
"AppointmentCategory"
Background
=
"{Binding SelectedItem.CategoryBrush, ElementName=PART_Categories}"
CornerRadius
=
"3"
Height
=
"20"
Margin
=
"6 6"
Grid.Row
=
"1"
Visibility
=
"{Binding SelectedItem, Converter={StaticResource NullToVisibilityConverter}, ElementName=PART_Categories}"
>
<
TextBlock
Margin
=
"6 0"
Text
=
"{Binding SelectedItem.DisplayName, ElementName=PART_Categories}"
VerticalAlignment
=
"Center"
/>
</
Border
>
<
Grid
x:Name
=
"Details"
Margin
=
"6"
Grid.Row
=
"2"
>
<
Grid.Resources
>
<
telerik:InputMode
x:Key
=
"RadDateTimePickerInputModeDatePicker"
>DatePicker</
telerik:InputMode
>
</
Grid.Resources
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"135"
/>
<
ColumnDefinition
Width
=
"*"
/>
<
ColumnDefinition
Width
=
"*"
/>
</
Grid.ColumnDefinitions
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"*"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
</
Grid.RowDefinitions
>
<
ItemsControl
Grid.Row
=
"0"
Grid.Column
=
"2"
Grid.RowSpan
=
"6"
Margin
=
"6"
ItemsSource
=
"{Binding Path=SelectedItem.Taches, ElementName=cmbProcessus}"
>
<
ItemsControl.ItemTemplate
>
<
DataTemplate
>
<
TextBlock
TextWrapping
=
"Wrap"
>
<
Run
>• </
Run
><
Run
Text
=
"{Binding Libelle}"
/>
</
TextBlock
>
</
DataTemplate
>
</
ItemsControl.ItemTemplate
>
</
ItemsControl
>
<
TextBlock
Grid.Row
=
"0"
Grid.Column
=
"0"
Margin
=
"6"
Text
=
"Processus"
/>
<
telerik:RadComboBox
x:Name
=
"cmbProcessus"
Grid.Row
=
"0"
Grid.Column
=
"1"
ItemsSource
=
"{Binding ElementName=RecurrentScheduleView, Path=DataContext.Processus, Mode=TwoWay}"
SelectedValue
=
"{Binding Path=Occurrence.Appointment.Process, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
DisplayMemberPath
=
"Libelle"
Margin
=
"2 1"
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
Loaded
=
"cmbProcessus_Loaded"
>
<
ToolTipService.ToolTip
>
<
ItemsControl
ItemsSource
=
"{Binding Path=SelectedItem.Taches, ElementName=cmbProcessus}"
>
<
ItemsControl.ItemTemplate
>
<
DataTemplate
>
<
TextBlock
>
<
Run
>• </
Run
><
Run
Text
=
"{Binding Libelle}"
/>
</
TextBlock
>
</
DataTemplate
>
</
ItemsControl.ItemTemplate
>
</
ItemsControl
>
</
ToolTipService.ToolTip
>
</
telerik:RadComboBox
>
<
TextBlock
Grid.Row
=
"1"
Grid.Column
=
"0"
Margin
=
"6"
Text
=
"Métier"
/>
<
telerik:RadComboBox
x:Name
=
"cmbWorks"
Grid.Row
=
"1"
Grid.Column
=
"1"
ItemsSource
=
"{Binding ElementName=RecurrentScheduleView, Path=DataContext.Metiers, Mode=TwoWay}"
SelectedValue
=
"{Binding Path=Occurrence.Appointment.Work, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
DisplayMemberPath
=
"Libelle"
Margin
=
"2 1"
Loaded
=
"cmbWorks_Loaded"
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
/>
<
TextBlock
Grid.Row
=
"2"
Grid.Column
=
"0"
Margin
=
"6"
Text
=
"Projet"
/>
<
telerik:RadComboBox
Grid.Row
=
"2"
Grid.Column
=
"1"
x:Name
=
"cmbProjects"
ItemsSource
=
"{Binding ElementName=RecurrentScheduleView, Path=DataContext.Projets, Mode=TwoWay}"
SelectedValue
=
"{Binding Path=Occurrence.Appointment.Project, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
DisplayMemberPath
=
"Libelle"
Margin
=
"2 1"
Loaded
=
"cmbProjects_Loaded"
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
/>
<
TextBlock
Grid.Row
=
"3"
Grid.Column
=
"0"
Margin
=
"6"
telerik:LocalizationManager.ResourceKey
=
"StartTime"
/>
<
telerik:RadDateTimePicker
Grid.Row
=
"3"
Grid.Column
=
"1"
TimeInterval
=
"0:30"
Culture
=
"{Binding DefaultCulture, Source={StaticResource LocalizationManager}}"
IsReadOnly
=
"{Binding IsReadOnly}"
IsEnabled
=
"{Binding IsNotRecurrent}"
Margin
=
"3"
SelectedValue
=
"{Binding ActualStart, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnDataErrors=true}"
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
>
<
telerik:RadDateTimePicker.InputMode
>
<
Binding
Converter
=
"{StaticResource BoolToInputModeConverter}"
Path
=
"IsAllDayEvent"
>
<
Binding.ConverterParameter
>
<
telerik:InputMode
>DatePicker</
telerik:InputMode
>
</
Binding.ConverterParameter
>
</
Binding
>
</
telerik:RadDateTimePicker.InputMode
>
</
telerik:RadDateTimePicker
>
<
TextBlock
Grid.Row
=
"4"
Grid.Column
=
"0"
Margin
=
"6"
telerik:LocalizationManager.ResourceKey
=
"EndTime"
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
VerticalAlignment
=
"Center"
/>
<
telerik:RadDateTimePicker
Grid.Row
=
"4"
Grid.Column
=
"1"
TimeInterval
=
"0:30"
Culture
=
"{Binding DefaultCulture, Source={StaticResource LocalizationManager}}"
IsReadOnly
=
"{Binding IsReadOnly}"
IsEnabled
=
"{Binding IsNotRecurrent}"
Margin
=
"3"
SelectedValue
=
"{Binding ActualEnd, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnDataErrors=true}"
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
>
<
telerik:RadDateTimePicker.InputMode
>
<
Binding
Converter
=
"{StaticResource BoolToInputModeConverter}"
Path
=
"IsAllDayEvent"
>
<
Binding.ConverterParameter
>
<
telerik:InputMode
>DatePicker</
telerik:InputMode
>
</
Binding.ConverterParameter
>
</
Binding
>
</
telerik:RadDateTimePicker.InputMode
>
</
telerik:RadDateTimePicker
>
<
TextBlock
Grid.Row
=
"5"
Grid.Column
=
"0"
Margin
=
"6"
Text
=
"Reunion"
/>
<
CheckBox
Grid.Row
=
"5"
Grid.Column
=
"1"
Margin
=
"3"
IsChecked
=
"{Binding Occurrence.Appointment.IsMeeting, Mode=TwoWay}"
/>
<
TextBlock
Grid.Row
=
"6"
Grid.Column
=
"0"
Margin
=
"6"
Text
=
"Heure supplémentaire"
/>
<
CheckBox
Grid.Row
=
"6"
Grid.Column
=
"1"
Margin
=
"3"
IsChecked
=
"{Binding Occurrence.Appointment.IsAdditionalHour, Mode=TwoWay}"
/>
</
Grid
>
<
Grid
Margin
=
"3"
Grid.Row
=
"3"
Visibility
=
"{Binding ResourceTypesVisibility}"
>
<
telerik:ItemsControl
x:Name
=
"PART_Resources"
BorderBrush
=
"{x:Null}"
BorderThickness
=
"0"
HorizontalContentAlignment
=
"Stretch"
IsTabStop
=
"false"
ItemsSource
=
"{Binding ResourceTypes}"
ItemTemplateSelector
=
"{StaticResource ResourcesEditorItemTemplateSelector}"
IsEnabled
=
"{Binding IsReadOnly, Converter={StaticResource InvertedBooleanConverter}}"
Margin
=
"3"
Visibility
=
"{Binding ResourceTypesVisibility}"
VerticalContentAlignment
=
"Stretch"
/>
<
TextBlock
HorizontalAlignment
=
"Center"
Margin
=
"3"
Text
=
"You can only change the resources by opening the series"
Visibility
=
"{Binding ResourceTypesVisibility, Converter={StaticResource InvertedVisibilityConverter}}"
/>
</
Grid
>
<
StackPanel
HorizontalAlignment
=
"Right"
Margin
=
"13 6"
Orientation
=
"Horizontal"
Grid.Row
=
"4"
>
<
telerik:RadButton
Command
=
"telerik:WindowCommands.Confirm"
Margin
=
"2"
MinWidth
=
"84"
telerik:LocalizationManager.ResourceKey
=
"Ok"
telerik:RadWindow.ResponseButton
=
"Accept"
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
>
<
ToolTipService.ToolTip
>
<
TextBlock
telerik:LocalizationManager.ResourceKey
=
"SaveAndClose"
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
/>
</
ToolTipService.ToolTip
>
</
telerik:RadButton
>
<
telerik:RadButton
Command
=
"telerik:WindowCommands.Cancel"
Margin
=
"2"
MinWidth
=
"84"
telerik:LocalizationManager.ResourceKey
=
"Cancel"
telerik:RadWindow.ResponseButton
=
"Cancel"
telerik:StyleManager.Theme
=
"{StaticResource Theme}"
/>
</
StackPanel
>
</
Grid
>
</
ControlTemplate
>
I would like to add validation to be sure than the user doesn't leave the combobox named "cmbWorks" empty ? how to proceed ?
I read this thread : http://www.telerik.com/community/forums/silverlight/scheduleview/ok-button-in-edit-appointment-dialog-window-is-disabled-for-new-appointment.aspx , this one http://www.telerik.com/community/forums/silverlight/scheduleview/how-to-validate-appointment-property-in-editappointmentdialog.aspx and also some others but it just added to my confusion :-( :
- In the sample : http://demos.telerik.com/silverlight/#ScheduleView/CustomAppointment, i don't see where the IDataError interface is implemented...
- also the link http://demos.telerik.com/silverlight/#DataValidation after loading is showing nothing on my side. Only the "silverlight" background is displaying
so, how to add this validation (don't leave empty the combobox) to have a custom error message displaying and the ok button disabled (just like it's the case if enddate < startdate) ?
thanks by advance for your answer, Regards,
Maxence