有沒有什麼辦法可以綁定到靜態類中的字段在Windows Phone 7中?如何綁定到Windows Phone 7中的靜態類的字段?
在WPF我可以寫類似
<ListBox ItemsSource="{Binding Source={x:Static local:TestStatic.Items}}" />
其中TestStatic被定義爲
public static class TestStatic
{
public static IEnumerable<string> Items
{ get { return new string[] { "Item A", "Item B", "Item C" }; } }
}
但這並不在WP7工作,錯誤是「類型 'X:靜態'沒找到。 ...」。
有沒有人有任何建議如何做到這一點?
爲什麼不在代碼後面做這個? 'ItemsSource =「{Binding}」'並且在代碼後面'this.listbox.ItemsSource = TestStatic.Items' – abhinav