问题
In WP7 I am used to generating sample data (XML) from my ViewModels in Blend and seeing them in Visual Studio.
In Blend 2012 I cannot find the option to generate design time data. The tempales in Visual Studio use design time data genarated in code. Is it the only way? No more XML design time data?
回答1:
I don't think generating design time data in Blend for VS2012 is possible, but it's still possible to use design time data created in code, but even this is more complicated than in WP7. Basically you have to use this construct in XAML to make it work:
<Page.Resources>
<CollectionViewSource x:Name="imagesSource" Source="{Binding Model.Images}"
d:Source="{Binding Model.Images, Source={d:DesignInstance Type=local:MainViewModel, IsDesignTimeCreatable=True}}"/>
</Page.Resources>
The important part here is the "d:DesignInstance" and "IsDesignTimeCreatable=True", the rest is quite similar to WP7.
回答2:
Not possible to use design time data in XML like in WP7
来源:https://stackoverflow.com/questions/12352724/design-time-data-in-windows-store-app