Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't Access 2+ Child of Databound Pivot
    primarykey
    data
    text
    <p>Ok, this is my first post here, so I'm not sure how detailed I need to be and I'm not the best at describing things, but I'll give it a shot.</p> <p>So on the main page of my App, when a user click on a textblock it sends them to the next page which is a dynamic pivot page:</p> <pre><code>&lt;Grid x:Name="LayoutRoot" Background="Transparent" DataContext="{Binding Products}"&gt; &lt;!--Pivot Control--&gt; &lt;controls:Pivot x:Name="Pivot" Title="{Binding name}" ItemsSource="{Binding pivots}"&gt; &lt;controls:Pivot.HeaderTemplate&gt; &lt;DataTemplate&gt; &lt;TextBlock Text="{Binding title}" /&gt; &lt;/DataTemplate&gt; &lt;/controls:Pivot.HeaderTemplate&gt; &lt;controls:Pivot.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;ListBox Margin="0,0,-12,0" ItemsSource="{Binding partners}"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel Margin="0,0,0,17" Width="432" Height="58"&gt; &lt;TextBlock Text="{Binding name}" TextWrapping="Wrap" Tap="showDetails" Style="{StaticResource PhoneTextExtraLargeStyle}"/&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; &lt;/DataTemplate&gt; &lt;/controls:Pivot.ItemTemplate&gt; &lt;/controls:Pivot&gt; &lt;/Grid&gt; </code></pre> <p>It passes a parameter that specifies what DataContext should be used on the page, and which pivot should be selected. OnNavigation, it then parse those parameters:</p> <pre><code>protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); string selectedType = this.NavigationContext.QueryString["type"]; string selectedPivot = this.NavigationContext.QueryString["pivot"]; int selectedIndex = 0; switch (selectedType) { case "product": LayoutRoot.DataContext = App.ViewModel.Products; selectedIndex = Array.IndexOf(App.ViewModel.ProductTypes, selectedPivot); break; case "service": LayoutRoot.DataContext = App.ViewModel.Services; selectedIndex = Array.IndexOf(App.ViewModel.ServiceTypes, selectedPivot); break; default: LayoutRoot.DataContext = App.ViewModel.Products; break; } Pivot.SelectedIndex = selectedIndex; PivotItem pivotItem = Pivot.ItemContainerGenerator.ContainerFromItem(Pivot.SelectedItem) as PivotItem; this.selectedList = FindFirstElementInVisualTree&lt;ListBox&gt;(pivotItem); } </code></pre> <p>The <a href="http://windowsphonegeek.com/tips/how-to-access-a-control-placed-inside-listbox-itemtemplate-in-wp7" rel="nofollow">FindFirstElementInVisualTree</a> is from <a href="http://windowsphonegeek.com/tips/how-to-access-a-control-placed-inside-listbox-itemtemplate-in-wp7" rel="nofollow">here</a></p> <p><strong>So here's my problem:</strong> This all works fine when I select the first dataset and the first pivot, otherwise it says that pivotItem doesn't have any children and throws an error.</p> <p>Any Idea's what I can do to get around this? Maybe I'm going about this all wrong. If you need more details, just let me know.</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.
    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