JosephGarrone
JosephGarrone

Reputation: 4161

ListView not showing ListViewItems

Hopefully this is an easy question! I have a listview with some items (These items do not change at all, so I am adding them in XAML not dynamically).

Here is the code:

   <ListView x:Name="SelectImageBox" ScrollViewer.HorizontalScrollBarVisibility="Disabled" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="72,53,60,20" Background="Transparent" Opacity="1">
        <ListView.ItemsPanel>
            <ItemsPanelTemplate>
                <WrapPanel IsItemsHost="True"/>
            </ItemsPanelTemplate>
        </ListView.ItemsPanel>
        <ListViewItem>
            <DynamicResource ResourceKey="Book"/>
        </ListViewItem>
        <ListViewItem>
            <DynamicResource ResourceKey="Book"/>
        </ListViewItem>
        <ListViewItem>
            <DynamicResource ResourceKey="Book"/>
        </ListViewItem>
        <ListViewItem>
            <DynamicResource ResourceKey="Book"/>
        </ListViewItem>
    </ListView>

My problem is that in the designer, it shows the 4 books. However, when I run the program, none of the items are displayed. If anyone could possibly explain what I'm missing?

Upvotes: 2

Views: 474

Answers (1)

JosephGarrone
JosephGarrone

Reputation: 4161

Okay, I fixed the problem. The listview items were getting added, except the image that they were using was being used by another control, the fix was to change the declaration in the resources to include x:Shared="False" (This does NOT show up in intellisense, but is legit code.

Upvotes: 2

Related Questions