PlexityHide

Home 

Products 

Downloads 

Our Shop 

Support 

Contact 


Saturday, October 2, 2010

How to create alternate rows in Gantt for Silverlight and WPF

image
   1: <local:BackgroundConverter x:Key="myConverter"/>
 
   1: <l:GanttRow Grid.Row="1"  ItemTemplate="{StaticResource TimeItemPres_blue_schedule}"  
   2:    ItemsSource="{Binding Path=Items}" 
   3:    Background="{Binding  Converter={StaticResource myConverter}}" ></l:GanttRow>

The Background is bound to “DataContext” that will be whatever the GanttRow represents – I add a Converter that can take my – in this case – DemoDataRow and turn it into a Brush:

   1: public sealed class BackgroundConverter : IValueConverter
   2: {
   3:  
   4:     #region IValueConverter Members
   5:  
   6:     public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
   7:     {
   8:         if (value is DemoDataRow)
   9:         {
  10:             LinearGradientBrush b=new LinearGradientBrush();
  11:             GradientStop gs1 = new GradientStop();
  12:             GradientStop gs2 = new GradientStop();
  13:             gs1.Color = Colors.Orange;
  14:             gs1.Offset = 0;
  15:             gs2.Color = Colors.Magenta;
  16:             gs2.Offset = 1;
  17:             
  18:             if ((value as DemoDataRow).Index%2==0)
  19:             {
  20:                 b.GradientStops.Add(gs1);
  21:                 b.GradientStops.Add(gs2);
  22:              
  23:                 return b;
  24:             }
  25:             else
  26:             {
  27:                 gs1.Offset=1;
  28:                 gs2.Offset=0;
  29:                 b.GradientStops.Add(gs1);
  30:                 b.GradientStops.Add(gs2);
  31:                 return b;
  32:             }
  33:                 
  34:         }
  35:         return new SolidColorBrush(Colors.Red);
  36:         
  37:     
  38:     }
  39:  
  40:     public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  41:     {
  42:         throw new NotImplementedException();
  43:     }
  44:  
  45:     #endregion
  46: }

Comments:
I am really impressed the way you have written the blog. Hope we are eagerly waiting for such post from your side. HATS OFF for the valuable information shared!
AWS Training in Chennai
AWS Course in Chennai

 
Your post about technology was very helpful to me. Very clear step-by-step instructions. I appreciate your hard work and thanks for sharing.
R Training in Chennai
R Programming Training in Chennai

 
Amazing article. Your blog helped me to improve myself in many ways thanks for sharing this kind of wonderful informative blogs in live. I have bookmarked more article from this website. Such a nice blog you are providing ! Kindly Visit Us R Programming institutes in Chennai
 
This comment has been removed by the author.
 

Post a Comment

Subscribe to Post Comments [Atom]





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]

Support

Support intro

Knowledgebase

FAQ phGantTimePackage

FAQ GTP.NET

FAQ general

History