Is there any way that I can bind to a field in a static class in windows phone 7?
In WPF I can write something like
<ListBox ItemsSource="{Binding Source={x:Static local:TestStatic.Items}}" />
where TestStatic is defined as
public static class TestStatic
{
public static IEnumerable<string> Items
{ get { return new string[] { "Item A", "Item B", "Item C" }; } }
}
but this doesn’t work in WP7, the error is “The type ‘x:Static’ was not found. …”.
Does anyone have any suggestions how to do this?
You can’t use the static markup extension in WP7 (which I find quite annoying). You will need to go with a workaround such as the one abhinav suggested.