Following the suggested solution from this post, I still can't get the design time data to show up for my Windows Phone app using a ListBox
of my custom type.
XAML
<Page
x:Class="MyApp.MainPage"
...
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
DataContext="{Binding MyCommunicator.MyClass}"
<UserControl.Resources>
<myCommunicator:MyClassDesignTime x:Key="DesignViewModel"/>
</UserControl.Resources>
<ListBox x:Name="ItemsListBox" d:DataContext="{Binding Source={StaticResource DesignViewModel}}">
...
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Name"/>
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Name}"/>
My custom type MyClassDesignTime
is inherited from MyClass
, has a parameterless constructor and static data that it returned from its properties (e.g. Name
). I don't get any error messages when building or running my app, but during design time I cannot see any data, just a blank screen (in the "phone preview" window beside my XAML
code.