WPF Binding not updating when binded object is updated

Posted by Chris Klepeis on Stack Overflow See other posts from Stack Overflow or by Chris Klepeis
Published on 2010-05-19T17:23:31Z Indexed on 2010/05/19 17:30 UTC
Read the original article Hit count: 185

Filed under:
|
|

I'm trying to bind to a custom control like so:

<my:GanttChartTaskListView Name="ganttChartTaskListView1" ItemsSource="{Binding Source={x:Static local:TaskCollection.taskList}}" />

In my WPF Window constructor I add add an item to my taskList, when it loads I can see that item in my custom control, however, when I subsequently add items it does not update. I tried setting Mode=TwoWay, however, then it says the "Path" is required and I'm not familiar with binding like that (this is new to me).

Here is my TaskCollection class:

namespace ProjectManager
{
    public static class TaskCollection
    {
        private static List<TaskItem> _taskList = new List<TaskItem>();

        public static List<TaskItem> taskList
        {
            get  {return _taskList; }
            set { _taskList = value; }
        }
    }
}

Any ideas? Is there a better / easier way to do this?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about databinding