How to set different color in one appointment?

4 posts, 0 answers
  1. Zhang
    Zhang avatar
    2 posts
    Member since:
    Nov 2014

    Posted 01 Dec 2014 Link to this post

    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.
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 02 Dec 2014 Link to this post

    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.

     
  3. DevCraft banner
  4. Zhang
    Zhang avatar
    2 posts
    Member since:
    Nov 2014

    Posted 11 Dec 2014 in reply to Yana Link to this post

    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.
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 12 Dec 2014 Link to this post

    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.

     
Back to Top