简体   繁体   中英

Wrappanel in ItemsControl.ItemsPanel throws XamlParseException

In my wp8 app I show some content (images for example). I use LongListSelector, and in each LLS's item have ItemsControl with collection of images. I want to show two images in one line, so I use a wrappanel. But it throws XamlParseException in line InitializeComponent() in usercontrol's page. Without wrappanel all works fine. Here the code

            <ItemsControl HorizontalAlignment="Center" ItemsSource="{Binding Vkontakte.Attachments.Photos}" >
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <toolkit:WrapPanel Height="100" Width="100" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>

            <ItemsControl.ItemTemplate>
                <DataTemplate>
                <Image Margin="0,10,0,0" >
                    <Image.Source>
                        <BitmapImage UriSource="{Binding Src}" CreateOptions="BackgroundCreation" />
                    </Image.Source>
                </Image>
            </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>

Maybe problem is in the case, that ItemsControl is in the StackPanel ?

The exception my be thrown due to your ItemsSource binding. If Vkontakte is not an object on your datacontext then you may need to take a look at what you are binding to. It needs to be a collection of some kind of object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM