可以&#t; t:绑定到全局ObservableCollection <type>

时间:2016-02-12 19:03:17

标签: c# data-binding winrt-xaml win-universal-app xbind

我使用了杰瑞的技术:

App-wide Observable Collection

并收到编译错误CS0176,并显示以下消息:

会员&#39; Page.Items&#39;无法使用实例引用访问;用类型名称来限定它。

我正在尝试x:绑定到ObservableCollection项目。

任何人都知道如何解决此错误。

感谢

1 个答案:

答案 0 :(得分:2)

So, I just double-checked, this time with cordova platform .

This is the code:

x:bind

And this is the XAML:

public class x
{
    public static ObservableCollection<string> Items { get; } = new ObservableCollection<string>();
}

public sealed partial class MainPage : Page
{
    public MainPage()
    {
        InitializeComponent();
    }

    public ObservableCollection<string> Items { get { return x.Items; } }
}

Works like a charm. Looks like this:

enter image description here

So, I am not sure why you are seeing this error. But, to your question, there is no fix because this works. If you figure out the problem you were getting be sure and follow-up with a comment. Otherwise, best of luck!