Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Background for single RowHeader (Read 3576 times)
hdbnoehfbo
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Nov 28th, 2014
Background for single RowHeader
Nov 28th, 2014 at 3:50pm
Print Post  
Hi,

I need to change the Header Background for specific rows, similar to
Code
Select All
calendar.ResourceViewSettings.HeaderStyle.Background = Brushes.White; 


but only for some rows. I generate the headers dynamically during startup before the calendar is displayed, so I need a method to change the backgroundcolor after I generated the data. How is it possible to do this?
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Background for single RowHeader
Reply #1 - Dec 1st, 2014 at 7:46am
Print Post  
Hi,

You can do that by using a custom RowHeaderTemplate. First, you can associate a brush with each resource through its Tag property. Alternatively you can define a custom resource class, which exposes a new property for the background brush.

Code
Select All
calendar.ItemResources.Add(new Resource() { Name = "resource 1", Tag = Brushes.Red });
calendar.ItemResources.Add(new Resource() { Name = "resource 2", Tag = Brushes.Green });
calendar.ItemResources.Add(new Resource() { Name = "resource 3", Tag = Brushes.Orange });
calendar.ItemResources.Add(new Resource() { Name = "resource 4", Tag = Brushes.Purple }); 


Then you can specify a custom RowHeaderTemplate, which binds to the background property:

Code
Select All
<p:Calendar x:Name="calendar" CurrentView="ResourceView">
	<p:Calendar.ResourceViewSettings>
		<p:ResourceViewSettings>
			<p:ResourceViewSettings.RowHeaderTemplate>
				<DataTemplate>
					<Border Background="{Binding Resource.Tag}">
						<TextBlock Text="{Binding HeaderText}" HorizontalAlignment="Center" VerticalAlignment="Center" />
					</Border>
				</DataTemplate>
			</p:ResourceViewSettings.RowHeaderTemplate>
		</p:ResourceViewSettings>
	</p:Calendar.ResourceViewSettings>
</p:Calendar> 


Finally, you need to set the appropriate alignment for the header content (by default it appears centered inside the header):

Code
Select All
calendar.ResourceViewSettings.HeaderStyle.HorizontalAlignment = HorizontalAlignment.Stretch;
calendar.ResourceViewSettings.HeaderStyle.VerticalAlignment = VerticalAlignment.Stretch; 


I hope this helps.

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


I Love MindFusion!

Posts: 3
Joined: Nov 28th, 2014
Re: Background for single RowHeader
Reply #2 - Dec 3rd, 2014 at 12:18pm
Print Post  
Thanks, this is exactly what I was looking for.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint