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

How to set different color in one appointment?

3 Answers 57 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Zhang
Top achievements
Rank 1
Zhang asked on 02 Dec 2014, 04:32 AM
I want to set different colors in one appointment. And i used to use AppointmentItemContentTemplate to try this business. But it didn't work. For example, in month view, it has a long appointment that across two lines. The first row shows two color red and green. And the second line shows the same color.But I wanna this line show green. Here is code.

<DataTemplate x:Key="AppointmentTemplate">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <StackPanel Orientation="Horizontal" Grid.ColumnSpan="2">
                    <Rectangle Width="{Binding Appointment.LWidth}" Fill="Red">
                    </Rectangle>
                    <Rectangle Width="{Binding Appointment.RWidth}" Fill="Green"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" Grid.Column="0">
                    <Image Source="../Images/Tester.png" Stretch="Fill" Width="20" Height="20"/>
                    <TextBlock Text="{Binding Path=Subject}" VerticalAlignment="Center"/>
                </StackPanel>
            </Grid>
        </DataTemplate>
Is any problem with this code? or this method cannot deal with this problem.
Can anyone help me to fix this problem? 

At last, I give my expected result that can help understanding.

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 02 Dec 2014, 12:24 PM
Hello Zhang,

I am afraid there is no easy way to calculate the needed width of the appointments as this depends on the size/number of the slots as well as the width the ScheduleView itself, furthermore the browser window can be expanded/shrunk, so this width to be updated.

As to the provided code - could you please tell us how the LWidth and RWidth properties of the appointment are defined?

Regards,
Yana
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Zhang
Top achievements
Rank 1
answered on 12 Dec 2014, 05:51 AM
I'm sorry for replying so late. Yes, as you say it's hard to calculate the width of the appointments. It only can get a close number by getting the actual width of ScheduleView and divided by 7. And the code i list before has some problem that i must use AppointmentItemTemplateSelector and create a new template with single color. Well, this is not a good idea. If you have other methods to set a different color in a appointment.I would be very grateful.

Best Regards.
0
Yana
Telerik team
answered on 12 Dec 2014, 12:56 PM
Hi Zhang,

Unfortunately there is no other way to set the background color of the appointments.

I am sorry for any inconvenience caused.

Regards,
Yana
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
ScheduleView
Asked by
Zhang
Top achievements
Rank 1
Answers by
Yana
Telerik team
Zhang
Top achievements
Rank 1
Share this question
or