0

Possible Duplicate:
Accessing static fields in XAML

I have one static class with two static properties inside. For example:

public static class myStaticClass
{
  public static A a;
  public static B b;
}

public class A
{
  public ObservableCollection<Person> persons;

  public struct Person
  {
    private string mame;

    public string Name
    {
      get; set;
    }
  }
}

public class B
{
  public ObservableCollection<Coord> coords;

  public struct Coord
  {
    private string address;

    public string Address
    {
      get; set;
    }

}

I initialize and fill myStaticClass.a and myStaticClass.b and I want bind properties (a, b) with listbox, which contains two textboxes (One textbox bind to person Name and the second with Address).

Could you help me please do it.

Thanks.

Community
  • 1
  • 1
shtuceron
  • 29
  • 1
  • 4
  • Also note that having mutable structs like this is a very bad idea... – Reed Copsey Aug 14 '12 at 20:01
  • 1
    You have a class that, essentially, holds two collections. A `ListBox` can accept only one collection as its `ItemsSource`. You either need to use two list boxes (which is a PITA if you need to sync scrolling), or to make a fourth class that combines the items of the two collections. I'd highly recommend the second path. – XAMeLi Aug 14 '12 at 20:04

1 Answers1

0

See the accepted answer in this question. In essence, you need to use x:Static in your XAML.

Community
  • 1
  • 1
Bernard
  • 7,908
  • 2
  • 36
  • 33