Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic WPF Scheduling: Item background depending on Appointment data (Read 5540 times)
Heli
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 44
Joined: Aug 29th, 2016
WPF Scheduling: Item background depending on Appointment data
Feb 23rd, 2017 at 9:43am
Print Post  
Hi,

I have my own Appointment class (derived from MindFusion.Scheduling.Appointment).
I'm using Theme Light.

I'd like to have the item background drawn with the color my Appointment class holds:
public System.Windows.Media.Brush Background { get; set; }

I'm afraid something like that won't work:
Code
Select All
<planner:Calendar.ItemSettings>
    <planner:ItemSettings>
        <planner:ItemSettings.CalendarStyle>
            <planner:CalendarStyle Background="{Binding ???}" />
            </planner:ItemSettings.CalendarStyle>
    </planner:ItemSettings>
</planner:Calendar.ItemSettings> 



Same question applies to Xamarin.Scheduling, how to do it there?

Regards,
Heli
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: WPF Scheduling: Item background depending on Appointment data
Reply #1 - Feb 23rd, 2017 at 1:08pm
Print Post  
Hi,

You should either create a custom item viewer for your appointments or use custom drawing and use the custom property to paint your items' background.

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


I Love MindFusion!

Posts: 44
Joined: Aug 29th, 2016
Re: WPF Scheduling: Item background depending on Appointment data
Reply #2 - Feb 23rd, 2017 at 1:40pm
Print Post  
Hi,

I guess, custom item viewer is something like in the sample "Scheduling.CustomItemTemplates"?
Maybe you can provide me the app.xaml contents like
<Style TargetType="{x:Type local:MyAppointmentPresenter}">
but based on Theme Light design.

And is there a sample for the second option, custom drawing, too?

Regards,
Heli
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: WPF Scheduling: Item background depending on Appointment data
Reply #3 - Feb 23rd, 2017 at 4:11pm
Print Post  
Hi,

The CustomItemTemplates sample illustrates exactly what you need, but its a lot of work to change the background of the item when you can simply use the item's Style for this purpose. Anyway, check the modified sample:

https://mindfusion.eu/_temp/_sample_CustomItemTemplates.zip

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


I Love MindFusion!

Posts: 44
Joined: Aug 29th, 2016
Re: WPF Scheduling: Item background depending on Appointment data
Reply #4 - Feb 23rd, 2017 at 4:26pm
Print Post  
Hi,

thank you for this sample, that's great!

Quote:
...you can simply use the item's Style for this purpose.

So, there is a much simplier way to set the appointment item background color depending on data stored in MyAppointment object?
Most probably I think too complicated, but I don't get it, sorry.
How can I achieve a data dependent appointment/item background the easiest way? Suitable for WPF and Xamarin.Scheduling.
Can you create a small sample, please?

At this point, I'd like to thank you for your great support.
You helped me a lot so far!

Regards,
Heli
« Last Edit: Feb 23rd, 2017 at 9:35pm by Heli »  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: WPF Scheduling: Item background depending on Appointment data
Reply #5 - Feb 24th, 2017 at 8:58am
Print Post  
Hi,

Check out this modified sample: https://mindfusion.eu/_temp/_sample_CustomItemTemplates2.zip.

The items no longer have custom presenters. Instead, when the state of an item changes (in response to a click for example), the item background is changed through its style. The style is associated with the item through the Calendar.SetItemStyle method.

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


I Love MindFusion!

Posts: 44
Joined: Aug 29th, 2016
Re: WPF Scheduling: Item background depending on Appointment data
Reply #6 - Feb 24th, 2017 at 12:02pm
Print Post  
Hi,

now I got your point.

I applied this idea to my application by holding a reference to the Calendar object within MyAppointment (data backing class). An event notifies MyAppointment about possible reference changes.

So, whenever a data property changes which should influence the UI (i.e. background color change), I set the style as you showed in the example within the MyAppointment property setter.

That works for me.
Thank you!

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