Show Appointment Dialog Using Code Behind

17 posts, 0 answers
  1. Moe
    Moe avatar
    5 posts
    Member since:
    Oct 2009

    Posted 26 Mar 2012 Link to this post

    I know you can double click the ScheduleView and show the add/edit appointment dialog, is it possible to show it using code behind (C#)?
  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 28 Mar 2012 Link to this post

    Hello Mohamed,

    In order to show the EditAppointmentDialog you can execute the EditAppointment Command of the ScheduleView, for example:

    RadScheduleViewCommands.EditAppointment.Execute(appointment, this.scheduleView);

    Where appointment is the newly created appointment.

    Regards,
    Konstantina
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 20 Apr 2012 Link to this post

    Hi,

    but is it possible to show the Appointment Dialog from somewhere else? I have my SchduleView on my Schedule.xaml Page. Somewhere else in my application i want to open the Appointment Dialog.

    Is that possible and how?

    thanks a lot
    Regads
    rene
  5. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 24 Apr 2012 Link to this post

    Hello Rene,

    If you have a reference to the ScheduleView and you give that reference to the Command, you should be able to open the dialog from somewhere else.

    Regards,
    Konstantina
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  6. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 25 Apr 2012 Link to this post

    Hi,

    but how do i set the reference to my scheduleview? Now i use this code to open the appointment (i try).

    private void test_Click(object sender, RoutedEventArgs e)
        {
            RadScheduleView RSvD = new RadScheduleView();
            Appointment appoint = new Appointment();
            RadScheduleViewCommands.EditAppointment.Execute(appoint, RSvD);
       }

    But i just get an empty box (attached).

    Thanks
    rene
  7. Mace
    Mace avatar
    4 posts
    Member since:
    Apr 2012

    Posted 14 May 2012 Link to this post

    Hi, i'm in the same situation, i create an appointment with the code behind with this code:
    RadScheduleView MyRadScheduleView = (sender as RadScheduleView);
    Appointment appointment = new Appointment();
    appointment.Subject = "New Appointment";
    appointment.Start = MyRadScheduleView.SelectedSlot.Start;
    appointment.End = MyRadScheduleView.SelectedSlot.End;                               
    foreach (Resource r in MyRadScheduleView.SelectedSlot.Resources.AsEnumerable())
    {                    
    appointment.Resources.Add(r);                    
    }                
    RadScheduleViewCommands.CreateAppointment.Execute(appointment, MyRadScheduleView);


    But when the EditAppointmentDialog appear, there is no resources selected, how i can selected resources?

    Thanks
    Gat
  8. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 14 May 2012 Link to this post

    Hi Gat,

    my problem ist, the appointment does not appear?!

    Thanks
    Rene
  9. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 17 May 2012 Link to this post

    Hello,

    Gat, could you please explain on which event you are adding the new appointment?
    Also, if you could give us some more details about the scenarios in which you experience the issue will be much helpful for tracking down the source of the issue. Sending us a sample application in which is illustrated your approaches and what you need to achieve will help us in providing you with solution in a timely manner.

    Looking forward to your replies.

    Greetings,
    Konstantina
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  10. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 17 May 2012 Link to this post

    Hi,

    it's quiet simple. I want to open the appointment dialog from somewhere in my project. Perhaps after cklicking a button.
     
    That's it!

    Thanks
    Best Regards
    Rene
  11. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 22 May 2012 Link to this post

    Hi Rene,

    As mentioned earlier, if you have a reference to the ScheduleView and you give that reference to the Command, you should be able to open the dialog from somewhere else.

    Greetings,
    Konstantina
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  12. Mace
    Mace avatar
    4 posts
    Member since:
    Apr 2012

    Posted 22 May 2012 Link to this post

    Hello Konstantina,

    I want create a new Custom Appointment after the user has selected a time slot at the Mouse_Up Event, my scheduleView call this method:

    private void ScheduleView_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
            {            
                if (sender is RadScheduleView)
                {
                    RadScheduleView MyRadScheduleView = (sender as RadScheduleView);


                    MyAppointment appointment = new MyAppointment
                                                  {
                                                      Subject = "New Appointment",
                                                      Start = MyRadScheduleView.SelectedSlot.Start,
                                                      End = MyRadScheduleView.SelectedSlot.End
                                                  };
                    foreach (Resource r in MyRadScheduleView.SelectedSlot.Resources.AsEnumerable())
                    {                    
                        appointment.Resources.Add(r);                    
                    }                
                    RadScheduleViewCommands.CreateAppointmentWithDialog.Execute(appointment, MyRadScheduleView);                
                }
            }


    But when the CreateAppointmentDialog appear, the ressource is not selected then my appointment then ressources.
    I just want my ressources are selected in the CreateAppointmentDialog.
     
  13. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 22 May 2012 Link to this post

    Hi,

    something like this:

    Telerik.Windows.Controls.RadScheduleView MyView = new Telerik.Windows.Controls.RadScheduleView();  
    Telerik.Windows.Controls.RadScheduleViewCommands.CreateAppointmentWithDialog.Execute(null, MyView);

    Thanks
    rene
  14. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 24 May 2012 Link to this post

    Hello all,

    # to Mace:

    CreateAppointment command expects the first parameter to be of type IDateSpan ( like Slot, for example) - that is why neither of the properties are not set in the dialog. I suggest to call the command like this:

    RadScheduleViewCommands.CreateAppointmentWithDialog.Execute(MyRadScheduleView.SelectedSlot, MyRadScheduleView);

    and subscribe to AppointmentCreating event and set the Subject of the new appointment in its handler:

    private void ScheduleView_AppointmentCreating(object sender, AppointmentCreatingEventArgs e)
    {
        e.Appointment.Subject = "New Appointment";
    }

    in this way the resources will be set without a problem.

    #to Rene:

    As explained earlier you should set the ScheduleView as a second parameter when using the command. But note that it should be the ScheduleView instance which is placed on the page, not a newly created one.

    Hope this helps.

    Greetings,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  15. Karthik
    Karthik avatar
    10 posts
    Member since:
    Apr 2016

    Posted 04 May Link to this post

    Hello,

    When i double on the ScheduleView, I want to get the details which was entering in an appointment. Mean to say i wanna store it locally(DB). How to achieve it??

    If any examples are there please share me, it may help me to solve this.

     

  16. Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 05 May Link to this post

    Hi Karthik,

    Can you please share some more details regarding the desired scenario? Where on the control you want to click? And which appointment exactly you need to get details for? If you mean when double clicking an Appointment, then you could hook to the ShowDialog event of RadScheduleView and extract the currently clicked Appointment from the event arguments.

    Hope this helps.

    Regards,
    Kalin
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  17. Karthik
    Karthik avatar
    10 posts
    Member since:
    Apr 2016

    Posted 05 May in reply to Kalin Link to this post

    Hello Kalin,

    Thanks for the reply. Gone through the ShowDialog and getting the details, but how to achieve it using MVVM architecture, Specifically when ShowDialog opens i wanna save Appointment details to my DB, but i couldn't able to recognize which event is firing. Even i have tried RadScheduleView_AppointmentCreated ,whether it is the correct method or wrong?? If yes, then can we do using MVVM??

     

    Thank You :)

  18. Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 08 May Link to this post

    Hi Karthik,

    Through the arguments of the event (the ViewMode property of the AppointmentDialogViewModel) you can find out if the dialog is opening for creating a new appointment or for editing an existing one. Please check the following snippet:

    private void radScheduleView_ShowDialog(object sender, ShowDialogEventArgs e)
    {
        var isAddingNew = (e.DialogViewModel as AppointmentDialogViewModel).ViewMode == AppointmentViewMode.Add;
    }

    You could use our EventToCommand behavior in order to execute a command in the ViewModel whenever the event is fired.

    Hope this helps.

    Regards,
    Kalin
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for WPF is Visual Studio 2017 Ready