This question is locked. New answers and comments are not allowed.
I have created the following GanttView in my XAML
And I have the following code behind...
I end up with 16 items in my collection but I see nothing in the control. Any suggestions? I've been experimenting with NotifyPropertyChanged in different places. I am not certain what the issue may be, though.
<telerik:RadGanttView HorizontalAlignment="Left" Name="radGanttView1" VerticalAlignment="Top" Width="950" Height="450" TasksSource="{Binding ItProjects}" telerik:StyleManager.Theme="Metro"> <telerik:RadGanttView.Columns> <telerik:ColumnDefinition MemberBinding="{Binding Duration}" Header="Duration" ColumnWidth="100" /> <telerik:ColumnDefinition MemberBinding="{Binding Start}" Header="Start" ColumnWidth="55" /> <telerik:ColumnDefinition MemberBinding="{Binding End}" Header="End" ColumnWidth="55"/> </telerik:RadGanttView.Columns> </telerik:RadGanttView>And I have the following code behind...
private ClientContext _ctx;private IEnumerable<ListItem> _items;private string _listName = "IT Projects";private List<GanttTask> _itProjects;public List<GanttTask> ItProjects{ get { if (_itProjects == null) { _itProjects = new List<GanttTask>(); } return _itProjects; } set { if (_itProjects != value) { _itProjects = value; NotifyPropertyChanged("ItProjects"); } }}public MainPage(){ InitializeComponent(); _itProjects = new List<GanttTask>(); GetItProjects(); this.DataContext = this;}private void GetItProjects(){ _ctx = ClientContext.Current; CamlQuery camlQry = new CamlQuery() { ViewXml = "<View><Query><Where><Neq><FieldRef Name=\"Status\" /><Value Type=\"Choice\">Completed</Value></Neq></Where><OrderBy><FieldRef Name=\"Title\" Ascending=\"True\" /></OrderBy></Query></View>" }; ListItemCollection listItems = _ctx.Web.Lists.GetByTitle(_listName).GetItems(camlQry); _items = _ctx.LoadQuery(listItems.Include( item => item["Title"], item => item.Id, item => item["StartDate"], item => item["DueDate"] )); _ctx.ExecuteQueryAsync(onQuerySucceeded, onQueryFailed);}private void onQuerySucceeded(object sender, ClientRequestSucceededEventArgs args){ Dispatcher.BeginInvoke(() => { foreach (ListItem item in _items) { try { ItProjects.Add(ConvertListItemToProject(item)); } catch (Exception ex) { MessageBox.Show("Exception: " + ex.Message + "Stack: "+ ex.StackTrace); } } NotifyPropertyChanged("ItProjects"); });}private void onQueryFailed(object sender, ClientRequestFailedEventArgs args){ //TODO: Set an error state. MessageBox.Show(args.ErrorDetails.ToString());}private GanttTask ConvertListItemToProject(ListItem item){ TimeSpan ts = DateTime.Parse(item["StartDate"].ToString()) - DateTime.Parse(item["DueDate"].ToString()); return new GanttTask(DateTime.Parse(item["StartDate"].ToString()), DateTime.Parse(item["DueDate"].ToString()), item["Title"].ToString());}I end up with 16 items in my collection but I see nothing in the control. Any suggestions? I've been experimenting with NotifyPropertyChanged in different places. I am not certain what the issue may be, though.