This is a migrated thread and some comments may be shown as answers.

how to prevent saving Appointment before i finished some custom logic

7 Answers 39 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Yi
Top achievements
Rank 1
Yi asked on 27 Nov 2013, 01:41 AM
because i binding the appointmentsource to DB.before click ok button,i should do some business rule.
how can i do 

7 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 28 Nov 2013, 11:17 AM
Hi Yi,

What I can suggest you is that you handle the DialogClosing of the ScheduleView. The event is fired when the EditAppointmentDialog is about to close and before the AppointmentSaving is fired. For more information about the ScheduleView events you can check the following article from our online help documentation:
http://www.telerik.com/help/silverlight/radscheduleview-events-overview.html

Hope this helps.

Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Yi
Top achievements
Rank 1
answered on 28 Nov 2013, 02:08 PM
sorry that i have used WCF RIA Services do my logic.
how i use this in this event base on asynchronous operation .
0
Kalin
Telerik team
answered on 29 Nov 2013, 01:11 PM
Hi Yi,

I understand now. What I can suggest you is to extract and modify the default EditAppointmentDialogTemplate and replace the Ok button with custom one bound to a Command in the ViewModel. This way will be able to execute the custom logic in that Command and when completed you can manually confirm the dialog.
The button should look as follows, note that you will also need to pass the button it self as a parameter:

<telerik:RadButton Content="Ok"
                DataContext="{StaticResource ViewModel}"
                Command="{Binding ButtonClick}"
                CommandParameter="{Binding RelativeSource={RelativeSource Self}}" />
 
And the command:

private void OnButtonClick(object obj)
{
    // do custom logic here and confirm the dialog when needed with the command below
    WindowCommands.Confirm.Execute(null, obj as RadButton);
}

As for the custom dialog you can check the following article from our online help documentation:
http://www.telerik.com/help/wpf/radscheduleview-features-custom-dialogs.html

Hope this helps.

Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Yi
Top achievements
Rank 1
answered on 02 Dec 2013, 01:31 AM
can i use it in default theme?
0
Kalin
Telerik team
answered on 02 Dec 2013, 08:24 AM
Hello Yi,

Yes, of course. You just need to extract the default ControlTemplate of the EditAppointmentDialog from the OfficeBlack theme. The needed XAML file is located in the Themes.Implicit folder which is inside of the installation folder of the controls.

If you have any further questions, let us know.

Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Yi
Top achievements
Rank 1
answered on 03 Dec 2013, 12:58 AM
 in this command i found i can't use this datacontext of this dialog.i want to use some properties of creating appointment.like starttime,endtime
0
Kalin
Telerik team
answered on 04 Dec 2013, 11:38 AM
Hello Yi,

What I can suggest you in this case is to pass the Grid which hold the Button as CommandParameter. This way you will have the ViewModel of the Grid as well as the Button which is inside of it (you will to name the Button in this case). The Button in the EditAppointmentDialog ControlTemplate should look like this (I have passed the Grid with name Details as a parameter):

<telerik:RadButton x:Name="CustomButton"
                     Margin="2" MinWidth="84"
                     Content="Ok" DataContext="{StaticResource ViewModel}"
                     Command="{Binding ButtonClick}"
                     CommandParameter="{Binding ElementName=Details}" />

And the Command in the ViewModel should look like shown below:
private void OnButtonClick(object obj)
{
    // Get the AppointmentDialogViewModel
    var grid = obj as Grid;
    var vm = grid.DataContext as AppointmentDialogViewModel;           
    // Do the additional logic here
    // ...
    // Confirm the dialog below
    var button = grid.FindName("CustomButton") as RadButton;
    WindowCommands.Confirm.Execute(null, button);
}

Hope this works for you.

Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ScheduleView
Asked by
Yi
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Yi
Top achievements
Rank 1
Share this question
or