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

related to use AppoitmentStyleSelector and AppointmentTemplateSelector

3 Answers 84 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Hardik
Top achievements
Rank 1
Hardik asked on 20 Jul 2011, 06:31 AM
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"
                    Margin="-2">
                <Grid>
                    <ToolTipService.ToolTip>
                        <StackPanel Orientation="Vertical"
                                    MaxWidth="225"
                                    MaxHeight="225">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Start, StringFormat=\{0:HH:mm\}}" />
                                <TextBlock Text="-" />
                                <TextBlock Text="{Binding End, StringFormat=\{0:HH:mm\}}" />
                            </StackPanel>
                            <TextBlock Text="{Binding Subject}"
                                       TextWrapping="Wrap" />
                        </StackPanel>
                    </ToolTipService.ToolTip>
                    <TextBlock Text=""
                               Width="1000" />
                    <TextBlock x:Name="XamlSubjectTextBlock"
                               Margin="7 0 18 0"
                               Width="{Binding Width, ElementName=XamlBorder}"
                               VerticalAlignment="Top"
                               HorizontalAlignment="Left"
                               TextTrimming="WordEllipsis"
                               Text="{Binding Subject}"
                               Foreground="Black"
                               TextWrapping="Wrap" />

                </Grid>
            </Border>
        </DataTemplate>

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"
                         TargetType="telerikWindowsControls:AppointmentItem">           
        </ControlTemplate>

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

<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.?


Thanks
H@rdik Pancholi

3 Answers, 1 is accepted

Sort by
0
Pana
Telerik team
answered on 27 Jul 2011, 08:27 AM
Hello,

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?

Regards,
Pana
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!

0
Hardik
Top achievements
Rank 1
answered on 27 Jul 2011, 11:24 AM
hi,

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.

Thanks
H@rdik Pancholi
0
palak
Top achievements
Rank 1
answered on 27 Jul 2011, 02:23 PM
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.
http://demos.telerik.com/silverlight/#ScheduleView/FirstLook 

Thanks & regards,
palak
Tags
ScheduleView
Asked by
Hardik
Top achievements
Rank 1
Answers by
Pana
Telerik team
Hardik
Top achievements
Rank 1
palak
Top achievements
Rank 1
Share this question
or