This is a migrated thread and some comments may be shown as answers.

Syncing problem between ScheduleView and GanttView

0 Answers 66 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
Natasha
Top achievements
Rank 1
Natasha asked on 06 Sep 2018, 01:51 PM

I have a and that are synced. When one or more appointments are selected in the , it updates the above by adding tasks (only the root task) to the source of the only if those tasks are not already in the list else the list is left as is. 

Now sometimes when I am selecting multiple appointments the bindings on the Textblock display incorrectly in the Ganttview as seen in the before and after pics. It's the correct object behind the display UI element, only its binding seems to be boggled up for some reason. Sometimes when selecting another appointment, the UI updates correctly but most of the time it doesn't.

I modified the event container -  

<ControlTemplate  x:Key="EventContainerTemplate2" TargetType="telerik:EventContainer">

- that I found in Telerik's dictionaries and added the following in order to display the text on the bars:

<TextBlock x:Name="txtBlock" Padding="5"
   Text="{Binding DataItem.Title}"
   FontSize="{Binding DataItem.Appearance.FontSize}"
   FontWeight="{Binding DataItem.Appearance.FontWeight, Converter={StaticResource ConvertStringToFontWeight}}"
   Foreground="{Binding DataItem.Appearance.HexForeground, Converter={StaticResource ConvertHexToBrush}}"/>

DataItem is a GanttTask that implements the IGanttTask interface.

 

Here is the code that executes when appointments are selected (on selection changed event) in the ScheduleView:

private void scheduleView_AppointmentSelectionChanged(object sender, SelectionChangedEventArgs e)
{
    if (vm != null && vm.SelectedAppointment != null && ViewMode == "Resource")
    {
        vm.GanttTaskList = new ObservableCollection<GanttTask>();
        List<string> ids = new List<string>();
        foreach(object o in this.scheduleView.SelectedAppointments)
        {
            AppointmentTask app = o as AppointmentTask;
            IPlanTask task = app.UnderlyingTask.RootParent;
            if(!ids.Contains(task.IPlanTaskID))
            {
                vm.GanttTaskList.Add(new GanttTask { UnderlyingTask = task });
                ids.Add(task.IPlanTaskID);
            }
        }
        
        this.ganttView.TasksSource = vm.GanttTaskList;
        vm.RaisePropertyChanged(nameof(vm.GanttTaskList));
    }
}

No answers yet. Maybe you can help?

Tags
GanttView
Asked by
Natasha
Top achievements
Rank 1
Share this question
or