This question is locked. New answers and comments are not allowed.
I am trying to make reusable Duration column. Something like this:
but it doesn't work. Start and End properties are never set.
Please help! Thanks
public class GridViewDurationColumn : GridViewDataColumn{ public DateTime Start { get { return (DateTime)GetValue(StartProperty); } set { SetValue(StartProperty, value); } } public static readonly DependencyProperty StartProperty = DependencyProperty.Register("Start", typeof(DateTime), typeof(GridViewDurationColumn), new PropertyMetadata(null)); public DateTime End { get { return (DateTime)GetValue(EndProperty); } set { SetValue(EndProperty, value); } } public static readonly DependencyProperty EndProperty = DependencyProperty.Register("End", typeof(DateTime), typeof(GridViewDurationColumn), new PropertyMetadata(null)); public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem) { var duration = End - Start; return new TextBlock() { Text = duration.ToString() }; } }<local:GridViewDurationColumn Start="{Binding StartDate}" End="{Binding EndDate}" IsReadOnly="True" />but it doesn't work. Start and End properties are never set.
Please help! Thanks