related to use AppoitmentStyleSelector and AppointmentTemplateSelector

4 posts, 0 answers
  1. Hardik
    Hardik avatar
    61 posts
    Member since:
    Jun 2011

    Posted 20 Jul 2011 Link to this post

    Hi support,

    My requirement is something like this I want to show some information into it also. Like appointment starting time, appointment end time and subject. Also want to differentiate appointment on different condition using different color..

    With all this one new requirement is there if some user don't have permission for delete the appointment  then he/she can't see delete button on appointment.

    I have done following things for this.

    Used  Appointment template selector class in which on different condition different template applied.One example of template is as below.

     <DataTemplate x:Key="SimpleAppointmentTemplate">
                <Border x:Name="XamlBorder"
                            <StackPanel Orientation="Vertical"
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding Start, StringFormat=\{0:HH:mm\}}" />
                                    <TextBlock Text="-" />
                                    <TextBlock Text="{Binding End, StringFormat=\{0:HH:mm\}}" />
                                <TextBlock Text="{Binding Subject}"
                                           TextWrapping="Wrap" />
                        <TextBlock Text=""
                                   Width="1000" />
                        <TextBlock x:Name="XamlSubjectTextBlock"
                                   Margin="7 0 18 0"
                                   Width="{Binding Width, ElementName=XamlBorder}"
                                   Text="{Binding Subject}"
                                   TextWrapping="Wrap" />


    As shown in bold color I show start and end time with subject in tooltip and only subject in appointment. Here I differentiate  appointment by foreground color. Like for simple appointment Black , Ongoing appointment Green, late started appointment Red etc....

    This all is maintain by Appointment Template selector class.
    Now I want to hide delete button so I have post to teleik and got replied that I should use appointmentStyleSeletor class and in that remove or hide that delete button for that style. So for that I have done as below.

     <ControlTemplate x:Key="AppointmentItemHorizontalControlTemplate"

    <Style x:Key="XamlWithOutDeleteButtonStyle" TargetType="telerikWindowsControls:AppointmentItem">
                <Setter Property="Template"
                        Value="{StaticResource AppointmentItemHorizontalControlTemplate}" />
                <Setter Property="Canvas.ZIndex"
                        Value="1" />

    <localScheduler:AppointmnetStyleSelector x:Name="StyleSelector1"  WithOutDeleteButtonStyle ="{StaticResource XamlWithOutDeleteButtonStyle}" />

    From AppointmnetStyleSelector  class as per condition I select this style and delete button gone. but now the problem is I am not able to get the template for this. I mean this style override my template . All apointments are shown with black foreground color.

    how can I resolve this ? Can you please create one example related to that? Is it need to use both class for my requirement ? Or It can be solved with one class only.?

    H@rdik Pancholi
  2. Pana
    Pana avatar
    748 posts

    Posted 27 Jul 2011 Link to this post


    You need to set both the StyleSelector and DataTemplateSelector and it should work just fine. The only reason I know that the DataTempalteSelector may fail in such case is setting the ContentTemplate in the Style that will set the DataTemplate and ignore the selector. The solution you describe sounds very well. Do you have some problems implementing it? Does in have problems?

    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. Hardik
    Hardik avatar
    61 posts
    Member since:
    Jun 2011

    Posted 27 Jul 2011 Link to this post


    Where I have set ContentTemplate in style?

     I set ControlTemplate in style.

    My problem is I want datatemplate and its style, and also want that delete button is also removed.

    With my current implementation I can get either of the thing.

    H@rdik Pancholi
  4. palak
    palak avatar
    102 posts
    Member since:
    May 2011

    Posted 27 Jul 2011 Link to this post

    Hello Hardik,

    If you want to access controltemplate and it's childs in codebehind, i was using approaches as below.
    private RadComboBox radComboBox;
    private void radComboBox_Loaded( object sender, RoutedEventArgs e )
    this.radComboBox = sender as RadComboBox;

    Also user specific appointment, below link can be helpful. 

    Thanks & regards,
Back to Top