<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:converters="using:FileTime.Uno.Converters"
    xmlns:i="using:Microsoft.Xaml.Interactivity"
    xmlns:ic="using:Microsoft.Xaml.Interactions.Core">
    <DataTemplate x:Key="ContainerItemTemplate">
        <Grid
            x:Name="ContainerItemTemplateRoot"
            Margin="0"
            Padding="0"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch">
            <Grid.Resources>
                <converters:ItemViewModeToBrushConverter
                    x:Key="TextForegroundConverter"
                    AlternativeBrush="AlternativeForegroundBrush"
                    DefaultBrush="ForegroundBrush"
                    SelectedBrush="SelectedItemForegroundBrush" />
            </Grid.Resources>
            <i:Interaction.Behaviors>
                <ic:DataTriggerBehavior
                    Binding="{Binding ViewMode, Converter={StaticResource EnumToStringConverter}}"
                    Value="Default">
                    <ic:ChangePropertyAction
                        PropertyName="Background"
                        Value="{ThemeResource ItemBackgroundBrush}" />
                </ic:DataTriggerBehavior>
                <ic:DataTriggerBehavior
                    Binding="{Binding ViewMode, Converter={StaticResource EnumToStringConverter}}"
                    Value="Alternative">
                    <ic:ChangePropertyAction
                        PropertyName="Background"
                        Value="{ThemeResource AlternativeItemBackgroundBrush}" />
                </ic:DataTriggerBehavior>
                <ic:DataTriggerBehavior
                    Binding="{Binding ViewMode, Converter={StaticResource EnumToStringConverter}}"
                    Value="Selected">
                    <ic:ChangePropertyAction
                        PropertyName="Background"
                        Value="{ThemeResource SelectedItemBackgroundBrush}" />
                </ic:DataTriggerBehavior>
            </i:Interaction.Behaviors>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Image
                Width="32"
                Height="32"
                Margin="10,0"
                Source="{Binding Converter={StaticResource ItemToImageConverter}}" />

            <ItemsControl
                Grid.Column="1"
                VerticalAlignment="Center"
                ItemsSource="{Binding DisplayName}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <ItemsStackPanel Orientation="Horizontal" />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <TextBlock
                                x:Name="DispalyText"
                                Foreground="{Binding DataContext.ViewMode, ElementName=ContainerItemTemplateRoot, Converter={StaticResource TextForegroundConverter}}"
                                Text="{Binding Text}"
                                TextDecorations="{Binding TextDecorations}" />
                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </Grid>
    </DataTemplate>

    <Style
        x:Key="ContentListViewItemStyle"
        TargetType="ListViewItem">
        <Setter Property="FocusVisualPrimaryThickness" Value="0" />
        <Setter Property="FocusVisualSecondaryThickness" Value="0" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Margin" Value="0" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <ContentPresenter 
                        Content="{TemplateBinding}"
                        ContentTemplate="{TemplateBinding ContentTemplate}" 
                        HorizontalAlignment="Stretch" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style
        x:Key="MainContentListViewItemStyle"
        BasedOn="{StaticResource ContentListViewItemStyle}"
        TargetType="ListViewItem">
        <Setter Property="IsTabStop" Value="True" />
    </Style>

    <Style
        x:Key="ContentListView"
        TargetType="ListView">
        <Setter Property="Transitions" Value="{x:Null}" />
        <Setter Property="ItemContainerTransitions" Value="{x:Null}" />
        <Setter Property="ItemContainerStyle" Value="{StaticResource MainContentListViewItemStyle}" />
        <Setter Property="ItemTemplate" Value="{StaticResource ContainerItemTemplate}" />
        <!--Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <ItemsPresenter />
                </ControlTemplate>
            </Setter.Value>
        </Setter-->
    </Style>

    <Style
        x:Key="NonMainContentListView"
        BasedOn="{StaticResource ContentListView}"
        TargetType="ListView">
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="AllowFocusOnInteraction" Value="False" />
        <Setter Property="SelectionMode" Value="None" />
        <Setter Property="ItemContainerStyle" Value="{StaticResource ContentListViewItemStyle}" />
    </Style>

</ResourceDictionary>
