Hey guys
Does anyone know why this binding is causing an error in the WPF designer? ("Exception has been thrown by the target of an invocation.")
XAML (partial):
<Window xmlns:local="clr-namespace:MyAppNamespace">
<DataGrid ItemsSource="{Binding Source={x:Static local:Clients.Instance},
Path=ClientList}" />
</Window>
C#:
namespace MyAppNamespace
{
public sealed class Clients
{
// Singleton pattern
public static readonly Clients Instance = new Clients();
private Clients() { }
static Clients()
{
clientList = new ObservableCollection<Client>();
PopulateClientList();
}
private static ObservableCollection<Client> clientList;
public static ObservableCollection<Client> ClientList
{
get { return clientList; }
set { clientList = value; }
}
public static void PopulateClientList()
{
// .. load client data from xml
}
public class Client
{
// ... expose public properties for fields in provided xml element
}
}
}