XAML Binding to static classes [duplicate]

限于喜欢 提交于 2020-01-17 04:47:18

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/11959788/xaml-binding-to-static-classes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!