Binding a single array cell to a WPF control

Posted by yomi on Stack Overflow See other posts from Stack Overflow or by yomi
Published on 2011-01-05T13:50:55Z Indexed on 2011/01/05 13:54 UTC
Read the original article Hit count: 146

Filed under:
|

Hi, I have a bool array of size 4 and I want to bind each cell to a different control. This bool array represents 4 statuses (false = failure, true = success). This bool array is a propery with a class:

class foo : INotifyPropertyChanged {
...
private bool[] _Statuses;
public bool[] Statuses
{
    get {return Statuses;}
    set {
            Statuses = value;
            OnPropertyChanged("Statuses");
        }
}

In XAML there are 4 controls, each one bound to one cell of the array:

... Text="{Binding Path=Statuses[0]}" ...
... Text="{Binding Path=Statuses[1]}" ...
... Text="{Binding Path=Statuses[2]}" ...
... Text="{Binding Path=Statuses[3]}" ...

The problem is that the notify event is raised only when I change the array itself and isn't raised when I change one value within the array, i.e, next code line raises the event:

Statuses = new bool[4];

but next line does not raises the event:

Statuses [0] = true;

How can I raise the event each time one cell is changed?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about binding