I'm struggling with a school project. I'm making a very basic application, that can read the content of a selected folder and display it in a ListView. I've created an interface called IFiles and have three sub-classes named: Image, Text and Folder. They all implement the IFiles interface. 

My problem is mostly regarding the design in XAML. Because I want each listview item to have it's own individual color based on what type of object it finds. So if its a Text file, the background color should be green, and if its an image it should be blue. My current solution partially works, but it does paint the entire row as I want it to. 

I can indeed choose a color for the ListViewItem, but I only know how to do it for all at once, not for a single row. 

This is my code: 

```
   <Window.Resources>
    <BitmapImage x:Key="ImgIcon" UriSource="/Images/photo.png" DecodePixelHeight="20" DecodePixelWidth="20"></BitmapImage>
    <BitmapImage x:Key="TextIcon" UriSource="/Images/textfile.png" DecodePixelHeight="20" DecodePixelWidth="20"></BitmapImage>

    <Style TargetType="{x:Type ListViewItem}">
        <Setter Property="Background" Value="Red"></Setter>
    </Style>

    <DataTemplate DataType="{x:Type model:Image}">
        <StackPanel Orientation="Horizontal" Background="Blue" >
            <Image Source="{DynamicResource ImgIcon}"></Image>
            <Label Content="Filename:"></Label>
            <Label Content="{Binding Name}"></Label>
            <Label Content="Size:"></Label>
            <Label Content="{Binding Size}"></Label>
        </StackPanel>
    </DataTemplate>
    <DataTemplate DataType="{x:Type model:Text}">
        <StackPanel Orientation="Horizontal" Background="Green" >
            <Image Source="{DynamicResource TextIcon}"></Image>
            <Label Content="Filename:"></Label>
            <Label Content="{Binding Name}"></Label>
            <Label Content="Size:"></Label>
            <Label Content="{Binding Size}"></Label>
        </StackPanel>
    </DataTemplate>
</Window.Resources>
<Grid>
    <Button Content="Load Folder" HorizontalAlignment="Left" Margin="315,355,0,0" VerticalAlignment="Top" Width="155" Height="40" Command="{Binding LoadFolderCMD}"/>
    <ListView ItemsSource="{Binding Files}" Margin="0,0,0,89" HorizontalAlignment="Left" Width="792"/>

</Grid>

```

This is what it looks like when I execute it:

[![Execution of the program](https://i.stack.imgur.com/bXD9S.png)](https://i.stack.imgur.com/bXD9S.png)

The red part should have the same color as the content inside of the particular row. 

Hope you can help me