Note that there are some explanatory texts on larger screens.

plurals
  1. POPanorama Binding on WP7, Items collection must be empty before using ItemsSource
    text
    copied!<p>i keep getting this error: Items collection must be empty before using ItemsSource, when i attempt to bind data to a Panorama control. below is my xaml snippet.</p> <pre><code>&lt;controls:Panorama x:Name="panorama"&gt; &lt;controls:PanoramaItem &gt; &lt;StackPanel&gt; &lt;TextBlock Text="{Binding Text}"/&gt; &lt;/StackPanel&gt; &lt;/controls:PanoramaItem&gt; &lt;/controls:Panorama&gt; </code></pre> <p>in my code behind (xaml.cs), i do something like this:</p> <pre><code>protected override void OnNavigatedTo(NavigationEventArgs e) { string id = NavigationContext.QueryString["id"]; ObservableCollection&lt;MyObject&gt; list = DataAccessService.get(id); panorama.ItemsSource = list; base.OnNavigatedTo(e); } </code></pre> <p>note that MyObject has a Text property. any help is appreciated.</p> <p>after modifying it per the link below, the same exception is still thrown.</p> <pre><code>&lt;controls:Panorama x:Name="panorama"&gt; &lt;controls:Panorama.HeaderTemplate&gt; &lt;DataTemplate&gt; &lt;TextBlock Text="{Binding Header}"/&gt; &lt;/DataTemplate&gt; &lt;/controls:Panorama.HeaderTemplate&gt; &lt;controls:PanoramaItem &gt; &lt;DataTemplate&gt; &lt;StackPanel&gt; &lt;TextBlock Text="{Binding Text}"/&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/controls:PanoramaItem&gt; &lt;/controls:Panorama&gt; </code></pre> <p>finally, after continuing further with the user below's help, this is the solution that got rid of the exception.</p> <pre><code>&lt;controls:Panorama x:Name="panorama"&gt; &lt;controls:Panorama.HeaderTemplate&gt; &lt;DataTemplate&gt; &lt;TextBlock Text="{Binding Header}"/&gt; &lt;/DataTemplate&gt; &lt;/controls:Panorama.HeaderTemplate&gt; &lt;controls:Panorama.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel&gt; &lt;TextBlock Text="{Binding Text}"/&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/controls:Panorama.ItemTemplate&gt; &lt;/controls:Panorama&gt; </code></pre>
 

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