locked
Nested Binding after migrating to 8.1

    Question

  • Hi all,

    I've migrated my app from Windows 8 to 8.1. After I've modified all changes, the app started.

    Now I have a problem with binding nested object. I try to demonstarte it in code:

    Parent GridView:

    <GridView x:Name="GVMain" 
                                VerticalAlignment="Top" 
                                SelectionMode="None"
                                Width="auto"
                                Padding="181,0,0,0"
                                BorderThickness="0">
    <GridView.ItemTemplate>                            
                            <DataTemplate>
                                <Grid Margin="0,0,0,0" Width="auto" VerticalAlignment="Top" x:Name="GCatalogNavi">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="405" />
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
    
                                    <StackPanel  Grid.Column="0" Orientation="Horizontal" >
                                        <StackPanel.Background>
                                            <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                <GradientStop Color="{Binding colorLeft}" Offset="0" />
                                                <GradientStop Color="{Binding colorRight}" Offset="1" />
                                            </LinearGradientBrush>
                                        </StackPanel.Background>
                                        <TextBlock Margin="10,0,20,10" TextWrapping="Wrap" Text="{Binding title}" FontSize="25" FontWeight="Light" VerticalAlignment="Bottom" Width="230" />
                                    </StackPanel>
                                    <GridView 
                                        ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext.subFolder}"                                  
                                        ItemContainerStyle="{StaticResource GVSub}"
                                        Grid.Column="1"
                                        SelectionMode="Single"
                                        x:Name="GVSubItems"
                                        SelectionChanged="GVCatSubItems_SelectionChanged">
                                    </GridView>
                                </Grid>
                            </DataTemplate>
                        </GridView.ItemTemplate>
    </GridView>

    I get an unhandled exception saying "Failed to assign to property 'Windows.UI.Xaml.Controls.ItemsControl.ItemsSource'." for the GridView GBSubItems if I'm setting the ItemsSource like

    GVMain.ItemsSource = items;

    Does anyone have an idea what I'm doing wrong. Before I migrated to 8.1 everything works fine.

    Thanks in advance


    Thursday, March 20, 2014 2:56 PM

Answers

  • Hi Matt,

    thanks for your answer. Yes, I'm quite sure the objects contain everything. Can I send you a sample project which throws the same error?

    //Edit:
    Don't worry about it. I solved it. Because it worked in Windows 8, I didn't see that I don't have to access the TemplatedParent but can access the binded object itself.

    Sorry for the inconvenience and many thanks for your help!

    • Edited by jev01 Friday, March 21, 2014 11:19 AM Problem solved
    • Marked as answer by jev01 Friday, March 21, 2014 11:19 AM
    Friday, March 21, 2014 9:40 AM

All replies

  • Are you sure that the objects contain everything they are supposed to contain?  What exactly does the collection consist of?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, March 20, 2014 7:42 PM
    Moderator
  • Hi Matt,

    thanks for your answer. Yes, I'm quite sure the objects contain everything. Can I send you a sample project which throws the same error?

    //Edit:
    Don't worry about it. I solved it. Because it worked in Windows 8, I didn't see that I don't have to access the TemplatedParent but can access the binded object itself.

    Sorry for the inconvenience and many thanks for your help!

    • Edited by jev01 Friday, March 21, 2014 11:19 AM Problem solved
    • Marked as answer by jev01 Friday, March 21, 2014 11:19 AM
    Friday, March 21, 2014 9:40 AM