Our Shop 



Saturday, October 2, 2010

How to create alternate rows in Gantt for Silverlight and WPF

   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: {
   4:     #region IValueConverter Members
   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;
  18:             if ((value as DemoDataRow).Index%2==0)
  19:             {
  20:                 b.GradientStops.Add(gs1);
  21:                 b.GradientStops.Add(gs2);
  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:             }
  34:         }
  35:         return new SolidColorBrush(Colors.Red);
  38:     }
  40:     public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  41:     {
  42:         throw new NotImplementedException();
  43:     }
  45:     #endregion
  46: }

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 is really too useful and have more ideas and keep sharing many techniques. Eagerly waiting for your new blog keep doing more.
cloud computing courses in bangalore
cloud computing training in bangalore
Aws Training in Bangalore
Aws Course in Bangalore
cloud training in bangalore
cloud computing institutes in bangalore
This comment has been removed by the author.
Incredible post I should say and a debt of gratitude is in order for the data. Schooling is certainly a tacky subject. Be that as it may, is still among the main subjects within recent memory. I appreciate your post and anticipate more. You have made some valid statements there. I looked on the web to study the issue and discovered a great many people will oblige your perspectives on this site...
how to make a paper airplane eagle | how to make a boomerang airplane | the eagle paper airplane | best paper airplane design for distance and accuracy | best paper airplanes for distance and speed | what is the best paper airplane design for distance | paper airplane that flies far and straight | nakamura lock paper airplane instructions | paper airplane templates for distance | science behind paper airplanes


Post a Comment

Subscribe to Post Comments [Atom]

<< Home

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

Subscribe to Posts [Atom]


Support intro


FAQ phGantTimePackage


FAQ general