i’m a WPF noob .
iv’e got a listbox which is bound to a Property of class Client
public class Client : INotifyPropertyChanged
{
private List<Player> peers ;
public List<Player> Peers
{
get { return peers; }
set
{
peers = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("Peers"));
}
}
}
the listbox parent’s datacontext is bound to a Client instance
GameDetailsPanel.DataContext = client;
the listbox is bounded as follows :
<ListBox.Items>
<Binding Path="Peers"></Binding>
</ListBox.Items>
to my understanding this is suppose to bound the list to the path relative to it’s parent’s
datacontext .. when i run the application i get the following error:
{"A 'Binding' cannot be used within a 'ItemCollection' collection. A 'Binding' can only be set on a DependencyProperty of a DependencyObject."}
any ideas what i’m doing wrong .
You need to set the
ItemsSourceto yourListofPlayers.