If you need to define a custom column displaying and allowing the end user to edit a task duration in days in Gantt Chart Library for WPF or Project Management Library for WPF you can do it by using the following code (C#), applicable within our Custom Data Binding sample application:
// Task class
public class CustomTaskItem : INotifyPropertyChanged
{
[...]
public int DaysDuration
{
get
{
int days = 0;
for (DateTime d = StartDate.Date;
d <= (FinishDate.TimeOfDay > TimeSpan.Zero ? FinishDate.Date : FinishDate.Date.AddDays(-1));
d = d.AddDays(1))
{
if ((TaskSchedule ?? Schedule.Standard).GetEffort(d, d.AddDays(1)) > TimeSpan.Zero)
days++;
}
return days;
}
set
{
DateTime d = StartDate.Date;
int days = value;
while (days > 0)
{
if ((TaskSchedule ?? Schedule.Standard).GetEffort(d, d.AddDays(1)) > TimeSpan.Zero)
days--;
d = d.AddDays(1);
}
FinishDate = d;
}
}
}
The associated GridViewColumn definition is presented below (XAML):
<GridViewColumn Header="Duration (days)">
<GridViewColumn.CellTemplate>
<DataTemplate>
<pdmc:TextBox
Value="{Binding Item.DaysDuration, ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"
IsReadOnly="{Binding HasChildren}" IsHidden="{Binding IsMilestone}"
IsDataReadOnly="{Binding IsItemDataReadOnly,
RelativeSource={RelativeSource AncestorType=pdmc:NodeListViewBase}}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>