This question is locked. New answers and comments are not allowed.
Hello,
I have a custom appointment class and a custom appointment edit template. I am using validation.
During the validation I would like to modify some of the dialog form values. I do see the property set in the custom appointment/validation class, however the custom dialog form does not show the changes. I have set the binding mode to twoWay.
I have a custom appointment class and a custom appointment edit template. I am using validation.
During the validation I would like to modify some of the dialog form values. I do see the property set in the custom appointment/validation class, however the custom dialog form does not show the changes. I have set the binding mode to twoWay.
<ControlTemplate x:Key="EditAppointmentTemplate" TargetType="telerik:SchedulerDialog"> <Grid Height="475" Loaded="GridLoaded1"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <telerik:RadToolBar x:Name="AppointmentToolbar" Grid.Row="0" Margin="-1 0 -1 3" BorderThickness="0 0 0 1" GripVisibility="Collapsed" 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> <TextBlock Margin="6 0" telerik:LocalizationManager.ResourceKey="EditRecurrence" Foreground="{StaticResource StrongBrush}" /> </telerik:RadButton> <telerik:RadButton x:Name="EditParentAppointmentButton" IsEnabled="{Binding IsReadOnly, Converter={StaticResource InvertedBooleanConverter}}" Command="telerik:RadScheduleViewCommands.EditParentAppointment" Visibility="{Binding CanEditParentAppointment, Converter={StaticResource BooleanToVisibilityConverter}}"> <ToolTipService.ToolTip> <TextBlock telerik:LocalizationManager.ResourceKey="EditParentAppointment" telerik:StyleManager.Theme="{StaticResource Theme}" /> </ToolTipService.ToolTip> <TextBlock Margin="4 0" telerik:LocalizationManager.ResourceKey="EditParentAppointment" Foreground="{StaticResource StrongBrush}" /> </telerik:RadButton> <telerik:RadToolBarSeparator /> </telerik:RadToolBar> <!--<Border x:Name="AppointmentCategory" Grid.Row="1" Height="20" Margin="6 6" Background="{Binding SelectedItem.CategoryBrush, ElementName=MessageTypes}" Visibility="{Binding SelectedItem, ElementName=MessageTypes,Converter={StaticResource NullToVisibilityConverter}}"> <TextBlock Margin="6 0" Text="{Binding SelectedItem.DisplayName, ElementName=MessageTypes}" Foreground="{StaticResource MainBrush}" VerticalAlignment="Center" /> </Border>--> <Border Grid.Row="1" Grid.RowSpan="3" Margin="6" BorderBrush="{Binding SelectedItem.CategoryBrush, ElementName=MessageTypes}" BorderThickness="1"/> <Grid x:Name="Details" Grid.Row="2" Margin="12"> <Grid.Resources> <telerik:InputMode x:Key="RadDateTimePickerInputModeDatePicker">DatePicker</telerik:InputMode> </Grid.Resources> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="120" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="150" /> </Grid.ColumnDefinitions> <TextBlock Grid.Row="0" Grid.Column="0" Margin="6" Height="40" MinHeight="40" telerik:LocalizationManager.ResourceKey="POC" VerticalAlignment="Center" HorizontalAlignment="Right" /> <TextBox Grid.Row="0" Grid.Column="1" Margin="3" MaxLength="255" HorizontalAlignment="Stretch" IsReadOnly="{Binding IsReadOnly}" Text="{Binding Occurrence.Appointment.Poc, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" TextWrapping="Wrap" AcceptsReturn="True" telerik:StyleManager.Theme="{StaticResource Theme}" /> <TextBlock Grid.Row="1" Grid.Column="0" Margin="6" telerik:LocalizationManager.ResourceKey="StartTime" HorizontalAlignment="Right" telerik:StyleManager.Theme="{StaticResource Theme}" /> <telerik:RadDateTimePicker Grid.Row="1" Grid.Column="1" Margin="3" IsReadOnly="{Binding IsReadOnly}" Culture="{Binding DefaultCulture,Source={StaticResource LocalizationManager}}" SelectedValue="{Binding Occurrence.Appointment.Start, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" IsEnabled="{Binding IsNotRecurrent}" telerik:StyleManager.Theme="{StaticResource Theme}" SelectionChanged="RadDateTimePicker_SelectionChanged_1" > <telerik:RadDateTimePicker.InputMode> <Binding ElementName="AllDayEventCheckbox" Path="IsChecked" Converter="{StaticResource BoolToInputModeConverter}"> <Binding.ConverterParameter> <telerik:InputMode>DatePicker</telerik:InputMode> </Binding.ConverterParameter> </Binding> </telerik:RadDateTimePicker.InputMode> </telerik:RadDateTimePicker> <TextBlock Grid.Row="2" Grid.Column="0" Margin="6" telerik:LocalizationManager.ResourceKey="EndTime" VerticalAlignment="Center" HorizontalAlignment="Right" telerik:StyleManager.Theme="{StaticResource Theme}" /> <telerik:RadDateTimePicker Grid.Row="2" Grid.Column="1" Margin="3" IsReadOnly="{Binding IsReadOnly}" Culture="{Binding DefaultCulture,Source={StaticResource LocalizationManager}}" SelectedValue="{Binding Occurrence.Appointment.End, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" IsEnabled="{Binding IsNotRecurrent}" telerik:StyleManager.Theme="{StaticResource Theme}"> <telerik:RadDateTimePicker.InputMode> <Binding ElementName="AllDayEventCheckbox" Path="IsChecked" Converter="{StaticResource BoolToInputModeConverter}"> <Binding.ConverterParameter> <telerik:InputMode>DatePicker</telerik:InputMode> </Binding.ConverterParameter> </Binding> </telerik:RadDateTimePicker.InputMode> </telerik:RadDateTimePicker> <CheckBox x:Name="AllDayEventCheckbox" Grid.Row="3" Grid.Column="1" Margin="3" VerticalAlignment="Center" IsChecked="{Binding Path=Occurrence.Appointment.IsAllDay, Mode=TwoWay}" IsEnabled="{Binding IsNotRecurrent}" telerik:LocalizationManager.ResourceKey="AllDayEvent" telerik:StyleManager.Theme="{StaticResource Theme}" /> </Grid> <StackPanel Grid.Row="3" Margin="12 12" HorizontalAlignment="Right" Orientation="Horizontal"> <telerik:RadButton Margin="2" MinWidth="84" Command="telerik:WindowCommands.Confirm" 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 Margin="2" MinWidth="84" Command="telerik:WindowCommands.Cancel" telerik:LocalizationManager.ResourceKey="Cancel" telerik:RadWindow.ResponseButton="Cancel" telerik:StyleManager.Theme="{StaticResource Theme}" /> </StackPanel> </Grid></ControlTemplate>public class CalendarEventAppointment : Appointment, IDataErrorInfo{ private String _poc; public String Poc { get { return _poc} set { _poc= value; OnPropertyChanged(() => Poc } } private DateTime _end; public override DateTime End { get { return _end; } set { _end = value; OnPropertyChanged(() => End); } } private DateTime _start; public override DateTime Start { get { return _start; } set { _start = value; OnPropertyChanged(() => Start); } } public override IAppointment Copy() { IAppointment appointment = new CalendarEventAppointment(); appointment.CopyFrom(this); return appointment; } public override void CopyFrom(IAppointment other) { base.CopyFrom(other); var appointment = other as CalendarEventAppointment; if (appointment != null) { IsOccurence = appointment.IsOccurence; Start = appointment.Start; End = appointment.End; Poc = appointment.Poc; SharepointGroupName = appointment.SharepointGroupName; } } public string Error { get { return ValidateAppointment(); } } public string this[string columnName] { get { switch (columnName) { case "Start": return ValidateStartDate(); case "End": return ValidateEndDate(); case "Poc": return ValidatePoc(); } return null; } } private string ValidateAppointment() { string errorString = ValidateStartDate(); errorString = ValidateEndDate(); return errorString; } private string ValidatePoc() { if (string.IsNullOrEmpty(Poc)) { return "POC must be entered"; } return null; } private string ValidateStartDate() { if (Start == DateTime.MinValue) { return "Start Date must be entered"; } if (End <= Start) { Poc = "test to set poc"; End = Start.AddHours(1); } return EndDateMustBeGreaterThanStartDate(); } private string ValidateEndDate() { if (End == DateTime.MinValue) { return "End Date must be entered"; } return EndDateMustBeGreaterThanStartDate(); } private string EndDateMustBeGreaterThanStartDate() { if (End <= Start) { { return "End Date must be greater than Start Date"; } } return null; } protected override void OnPropertyChanged<P>(System.Linq.Expressions.Expression<Func<P>> propertyExpression) { base.OnPropertyChanged<P>(propertyExpression); CommandManager.InvalidateRequerySuggested(); }}