Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use CollectionViewSource with design time data in Expression Blend?
    primarykey
    data
    text
    <p>I wonder how I can show design time data in Expression Blend that is located inside a SampleData.xaml using a CollectionViewSource? Before changing my code to use the CVS, I used an ObservableCollection. I was in the need to filter and sort the items inside there, thus I changed the code to use the CVS. Now my designer complains about not being able to fill the SampleData's NextItems with a proper structure to show up in Expression Blend. Here is some code I use inside the app:</p> <p>MainViewModel.cs</p> <pre><code>class MainViewModel { public MainViewModel() { AllItems = new ObservableCollection&lt;ItemViewModel&gt;(); NextItems = new CollectionViewSource(); NextItems.Source = AllItems; } public CollectionViewSource NextItems { get; private set; } public ObservableCollection&lt;ItemViewModel&gt; AllItems { get; private set; } some functions to fill, filter, sort etc... } </code></pre> <p>MainView.xaml:</p> <pre><code>&lt;phone:PhoneApplicationPage ... some other stuff ... d:DesignWidth="480" d:DesignHeight="728" d:DataContext="{d:DesignData SampleData/SampleData.xaml}"&gt; &lt;Grid x:Name="LayoutRoot" Background="Transparent"&gt; &lt;controls:Panorama&gt; &lt;controls:PanoramaItem&gt; &lt;ListBox ItemsSource="{Binding NextItems.View}"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel&gt; &lt;Image Source="{Binding Image}" /&gt; &lt;StackPanel&gt; &lt;TextBlock Text="{Binding FullName}" /&gt; &lt;/StackPanel&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; &lt;/controls:PanoramaItem&gt; &lt;/controls:Panorama&gt; &lt;/Grid&gt; &lt;/phone:PhoneApplicationPage&gt; </code></pre> <p>SampleData.xaml</p> <pre><code>&lt;local:MainViewModel xmlns:local="clr-namespace:MyAppNamespace" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:swd="clr-namespace:System.Windows.Data;assembly=System.Windows" &gt; &lt;local:MainViewModel.AllItems&gt; &lt;local:ItemModel FullName="Dummy" Image="/Images/dummy.png" /&gt; &lt;/local:MainViewModel.AllItems&gt; &lt;local:MainViewModel.NextItems&gt; How to fill the CollectionViewSource's Source? &lt;/local:MainViewModel.NextItems&gt; &lt;/local:MainViewModel&gt; </code></pre> <p>So the question I can't find an answer to is how to fill the Source for NextItems in SampleDate.xaml? Any help would be much appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload