In WPF, I've built a habit when I'm building a UI to have some sample data that I bind in the XAML to a ListBox.ItemsSource so that I can see what the list will look like in the designer. In WPF, I would do it by making a static property that returns the fake data and then use it like this:
and it would work fine for displaying sample data in the designer.
I tried to do the same thing in Silverlight, and quickly found that x:Static isn't supported in Silverlight. (I'm just transistioning from WPF for some Silverlight work so I might be making newb SL mistakes.) I modified it to the following: (customerPage is the name of the "MyClass" class element in the XAML)
This binding works if I run the app, but doesn't work in the designer. (Which defeats much of the purpose of doing it to make designing easier/faster.)
Is there a Silverlight friendly code pattern to get sample data in the designer? (NOTE: Sample data is datatypes that cannot be represented in XAML, so I can't just make sample data in XAML.)
Code:
<ListBox Name="lbCustomers" ItemsSource="{x:Static MyClass.FakeCustomerForDesignView}" />
I tried to do the same thing in Silverlight, and quickly found that x:Static isn't supported in Silverlight. (I'm just transistioning from WPF for some Silverlight work so I might be making newb SL mistakes.) I modified it to the following: (customerPage is the name of the "MyClass" class element in the XAML)
Code:
<ListBox Name="lbCustomers" ItemsSource="{Binding ElementName=customerPage, Path=FakeCustomerForDesignView}" />
This binding works if I run the app, but doesn't work in the designer. (Which defeats much of the purpose of doing it to make designing easier/faster.)
Is there a Silverlight friendly code pattern to get sample data in the designer? (NOTE: Sample data is datatypes that cannot be represented in XAML, so I can't just make sample data in XAML.)