ListView messing up the UI of DataTemplates

Question!

I'm porting my WP8.1 app to UWP and I discovered that the new universal ListView likes to mess around with the UI of DataTemplaes by adding some extra elements and logic (like some background colors when the mouse covers an item).

Let's say I have a very simple template like this:

<DataTemplate x:Key="IconsTemplate">
    <Grid Width="40"
          Height="40">
        <Image Source="{Binding IconImage}"/>
    </Grid>
</DataTemplate>

And this ListView:

<ListView ItemTemplate="{StaticResource IconsTemplate}"
          ItemsSource="{x:Bind ViewModel.Source, Mode=OneWay}"
          CanReorderItems="False">
    <ListView.ItemsPanel>
        <ItemsPanelTemplate>
            <ItemsWrapGrid Orientation="Horizontal"/>
        </ItemsPanelTemplate>
    </ListView.ItemsPanel>
</ListView>

I'd expect to get, just like on WP8.1, a simple wrap grid with my 40*40 items with an image inside them. Instead, I get this:

ListView result

Every item is rectangular instead of square (I mean, those are clearly not my 40*40 templates), and I also have an automatic logic on the background color of my templates.

I don't want any of that, I want my templates to be displayed exactly as they are, and I want to be able to manually set my logic for the pointer events.

I tried looking at the default ListView template but I didn't find anything useful there, is there a parameter I'm missing or is there a way to just get the ListView to display the plain items like it used to do in WP8.1?



Answers

I managed to fix the issue by using a custom Style for the ListViewItems. Here is the Style I used:



This video can help you solving your question :)
By: admin