Multiple appointment types

3 posts, 1 answers
  1. Claire
    Claire avatar
    24 posts
    Member since:
    Apr 2015

    Posted 29 Oct 2015 Link to this post

    I need to have more than one appointment type, let's them be AppX and AppY, both derived from your Appointment class. One may have properties that the other does not, but at a minimum both have a subject, a start time and end time.

    The AppointmentsSource property being bound to a Collection of Appointment objects, I can thus add AppX and AppY objects to it. 

    So far, so good. Each appointment type is displayed in the schedule the way I want (I use a different template for each type).

    Now I want to be able to show a create/edit dialog that is customized to each type of appointment. DialogX and DialogY would be associated to AppX and AppY, respectively. And if the user double-clicks on an empty slot, I want to create an appointment of type AppX through DialogX.

    This is where I'm stuck.

    I thought of hooking to the AppointmentCreating and AppointmentEditing events, and show the appropriate dialog there. Is this the correct technique?

    Or would you not happen by any chance to have a sample that illustrates how this could be done?

     

  2. Claire
    Claire avatar
    24 posts
    Member since:
    Apr 2015

    Posted 30 Oct 2015 in reply to Claire Link to this post

    A better solution than hooking to the events mentioned would be to make use of a template selector to select the appropriate dialog template based on the appointment type.

    Here's a summary:

    1. Set up the RadScheduleView's EditAppointmentDialogStyle property
    tlk:RadScheduleView  EditAppointmentDialogStyle="{StaticResource myEditAppointmentDialogStyle}" ...

    2. Set up the Style's Template property
    <Style x:Key="myEditAppointmentDialogStyle" TargetType="tlk:SchedulerDialog">
    <Setter Property="Template" Value="{StaticResource myEditAppointmentTemplate}" />
    ...
    </Style>

    3. ControlTemplate looks like this:
    <ControlTemplate x:Key="myEditAppointmentTemplate" TargetType="tlk:SchedulerDialog">
    <DockPanel  x:Name="DialogRoot" >
    <ContentControl  
    Content="{Binding DataContext.Occurrence.Appointment, ElementName=DialogRoot}" 
    ContentTemplateSelector="{StaticResource myDialogTemplateSelector}">
    </ContentControl >
    </DockPanel>
    </ControlTemplate>

    4. Definition of actual template selector
    <views:DialogTemplateSelector 
       TypeXTemplate="{StaticResource myTypeXTemplate}" 
       TypeYTemplate="{StaticResource myTypeYTemplate}" 
       x:Key="myDialogTemplateSelector" />

    5.  The data templates for each appointment type:
    <DataTemplate x:Key="myTypeXTemplate">
    <DockPanel>
    <DockPanel.Resources>
    <viewmodels:EditTypeXDialogViewModel
    Appointment="{Binding}"
    x:Key="CustomDialogXViewModel" />
    </DockPanel.Resources>
    ...
    </DockPanel>
    </DataTemplate>

    <DataTemplate x:Key="myTypeYTemplate">
    <DockPanel>
    <DockPanel.Resources>
    <viewmodels:EditTypeYDialogViewModel
    Appointment="{Binding}"
    x:Key="CustomDialogYViewModel" />
    </DockPanel.Resources>
    ...
    </DockPanel>
    </DataTemplate>

    6. In the DialogTemplateSelector class (derived from DataTemplateSelector), method SelectTemplate returns the template type based on the type of the item argument: if type is AppY, return TypeYTemplate, else return TypeXTemplate. 

     

  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    Nasko
    Admin
    Nasko avatar
    585 posts

    Posted 02 Nov 2015 Link to this post

    Hi Claire,

    Thank you for sharing with the community your approach. Indeed the chosen by you solution of using a Template selector is the most appropriate one. Basically you could create as many EditAppointmentDialogStyles as you need and apply them for the the different types of Appointments.

    The other approach of using AppointmentCreating and AppointmentEditing events seems to be also an appropriate one, so based on your scenario you could choose which one best suits it and use it.

    If you have any additional questions or concerns regarding Telerik controls, please do not hesitate to contact us.

    Regards,
    Nasko
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top