Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Change colour of individual days (Read 6548 times)
Sean
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: Mar 30th, 2012
Change colour of individual days
Mar 30th, 2012 at 2:27pm
Print Post  
I have read on this forum how to change the colour of a lane in the resource view. I would also like to achieve a similar effect in other views, i.e. changing the background colour of certain days. Is this possible? If so can anybody tell me how?
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Change colour of individual days
Reply #1 - Mar 30th, 2012 at 3:08pm
Print Post  
You can create custom CellPresenter for this purpose (with custom control template), then handle the Calendar.CellPresenterCreating event and assign an instance of the custom CellPresenter class to the CellPresenter property of the accompanying event argument. The DualView sample illustrates how to do this. Let me know if you need an example code.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Sean
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: Mar 30th, 2012
Re: Change colour of individual days
Reply #2 - Mar 30th, 2012 at 4:27pm
Print Post  
Hi

Thanks for your prompt response.

I have created a custom template for the cell presenter as follows:

Code (HTML)
Select All
<Style x:Key="DiesNonCellStyle" TargetType="{x:Type planner:CellPresenter}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding StyleKey, RelativeSource={RelativeSource Self}}" Value="Simple">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type planner:CellPresenter}">
                                <Border DataContext="{Binding Path=., RelativeSource={RelativeSource TemplatedParent}}"
									BorderBrush="{Binding CellStyle.BorderBrush}"
									BorderThickness="{Binding CellStyle.BorderThickness}"
									Margin="{Binding CellStyle.Margin}">

                                    <Border.Background>
                                        <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                                            <GradientStop Color="DarkSlateGray"  Offset="0"/>
                                            <GradientStop Color="#FFCCCCCC" Offset="0.5"/>
                                            <GradientStop Color="DarkSlateGray" Offset="1.0"/>
                                        </LinearGradientBrush>
                                    </Border.Background>
                                  </Border>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
            </DataTrigger>
      </Style.Triggers>
</Style> 



I have added an event handler for CellPresenterCreated, which uses this template for certain days. This works fine in the ResourceView, but is not applied in any other view. The handler is invoked for the other views, the template is apparently assigned but there are no visible changes except in the ResourceView. This is my problem.

Sean
  
Back to top
 
IP Logged
 
Sean
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: Mar 30th, 2012
Re: Change colour of individual days
Reply #3 - Mar 30th, 2012 at 4:33pm
Print Post  
I've just worked out what it is - it's the DataTrigger in that template which is restricting which views it is applied to.

Having removed the DataTrigger it now works in all views, however I obviously need a different template with different datatriggers for the other views as the top of the cell, with the date in it, is being overwritten.

Would anybody happen to have an example custom cell presenter template for the other available views?

Thanks!

Sean
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Change colour of individual days
Reply #4 - Apr 1st, 2012 at 6:09am
Print Post  
The complete default item template can be found here: www.mindfusion.eu/onlinehelp/wpfplanner/index.htm?The_Default_Item_Template.htm. Keep in mind that we are currently in the process of making some changes to the control in order to improve its performance (among other things). These changes will affect the default item template as well as the way item presenters are used - more specifically an existing item presenter, which is no longer in use, can be reused for another item.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Sean
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: Mar 30th, 2012
Re: Change colour of individual days
Reply #5 - Apr 4th, 2012 at 7:22am
Print Post  
Hi

Thanks for your reply.

What I actually needed was the default cell presenter template, but I've found that now.

Thanks

Sean
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Change colour of individual days
Reply #6 - Apr 4th, 2012 at 8:16am
Print Post  
My mistake. In case others are interested in the default cell template, it can be found here.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint