<?xml version="1.0" encoding="utf-8"?>
<ResourceDictionary
    xmlns="www.team-mediaportal.com/2008/mpf/directx"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:collections="clr-namespace:MediaPortal.UI.Presentation.DataObjects;assembly=MediaPortal.UI"
    xmlns:mp_special_controls="clr-namespace:MediaPortal.UI.SkinEngine.SpecialElements.Controls;assembly=SkinEngine"
    xmlns:navitems="clr-namespace:MediaPortal.Plugins.SlimTv.Client.Models.Navigation;assembly=SlimTv.Client"
    xmlns:tv="clr-namespace:MediaPortal.Plugins.SlimTv.Client.Controls;assembly=SlimTv.Client"
    xmlns:fanart="clr-namespace:MediaPortal.Extensions.UserServices.FanArtService.Client;assembly=FanArtService.Client"
    DependsOnStyleResources="SlimTvColors,SlimTvConsts,FullScreenContentConsts,MediaButtons,MediaColors,Consts,MediaConsts,Colors,Buttons,OtherControls,MediaStyles,OSD"
    >
  <!-- SlimTvClient model -->
  <Model x:Key="SlimTvClient" Id="8BEC1372-1C76-484c-8A69-C7F3103708EC"/>
  <Model x:Key="SlimTvMultiChannelGuide" Id="5054408D-C2A9-451f-A702-E84AFCD29C10"/>
  <Model x:Key="TimeModel" Id="E821B1C8-0666-4339-8027-AA45A4F6F107"/>
  <Model x:Key="VideoPlayerModel" Id="4E2301B4-3C17-4a1d-8DE5-2CEA169A0256"/>
  <tv:SlimTvDateFormatConverter x:Key="SlimTvDateFormatConverter" />

  <Style x:Key="PrimarySlimTvOSDStyle" TargetType="{x:Type mp_special_controls:PlayerControl}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type mp_special_controls:PlayerControl}">
          <ControlTemplate.Resources>
            <Model x:Key="VideoPlayerModel" Id="4E2301B4-3C17-4a1d-8DE5-2CEA169A0256"/>
          </ControlTemplate.Resources>

          <Control Style="{ThemeResource OSDContainer}" Width="{ThemeResource FullScreenContentVideoPrimaryPlayerOSDWidth}" DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
            <Control.Resources>
              <ControlTemplate x:Key="OSD_Cover_Template">
                <Image x:Name="ChannelLogo" Stretch="Uniform" Width="120" Margin="10" VerticalAlignment="Top">
                  <Image.Source>
                    <fanart:FanArtImageSource fanart:FanArtMediaType="ChannelTv" fanart:FanArtType="Banner" fanart:FanArtName="{Binding Source={StaticResource SlimTvClient}, Path=ChannelName}"
                                              fanart:MaxWidth="0" fanart:MaxHeight="0"/>
                  </Image.Source>
                </Image>
              </ControlTemplate>
              <ControlTemplate x:Key="OSD_InfoArea_Template">

                <DockPanel LastChildFill="true" Margin="3">

                  <Grid DockPanel.Dock="Center" HorizontalAlignment="Stretch">
                    <Grid.ColumnDefinitions>
                      <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                      <RowDefinition Height="Auto"/>
                      <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>

                    <Label x:Name="CurrentProgramTitleLabel" Grid.Column="0" Content="{Binding Source={StaticResource SlimTvClient},Path=CurrentProgram.Title}" Scroll="Auto"
                        HorizontalAlignment="Left" VerticalAlignment="Center"
                        IsVisible="{Binding Source={StaticResource SlimTvClient},Path=!IsOSDLevel2}"
                        Color="{ThemeResource TextColor}"
                        FontFamily="DefaultBold" />

                    <Label x:Name="NextProgramTitleLabel"  Grid.Column="0" Grid.Row="1" Content="{Binding Source={StaticResource SlimTvClient},Path=NextProgram.Title}" Scroll="Auto"
                        HorizontalAlignment="Left" VerticalAlignment="Center"
                        IsVisible="{Binding Source={StaticResource SlimTvClient},Path=IsOSDLevel0}"
                        Color="{ThemeResource NextProgramLabelColor}" />

                    <!-- Title lable for OSD Level 2 (next program) -->
                    <Label x:Name="NextProgramTitleLabelLevel2" Grid.Column="0" Content="{Binding Source={StaticResource SlimTvClient},Path=NextProgram.Title}" Scroll="Auto"
                        HorizontalAlignment="Left" VerticalAlignment="Center"
                        IsVisible="{Binding Source={StaticResource SlimTvClient},Path=IsOSDLevel2}"
                        Color="{ThemeResource NextProgramLabelColor}"
                        FontFamily="DefaultBold" />


                    <!-- Current Program detailed information -->
                    <Grid Grid.Column="0" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                        IsVisible="{Binding Source={StaticResource SlimTvClient},Path=IsOSDLevel1}">
                      <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                      </Grid.RowDefinitions>
                      <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="300"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="15"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                      </Grid.ColumnDefinitions>
                      <Label x:Name="Channel" Grid.Row="0" Grid.Column="0" Scroll="Auto"
                          Content="{Binding Source={StaticResource SlimTvClient},Path=ChannelName}"
                          Color="{ThemeResource TextColor}"/>

                      <Label x:Name="ProgramStart" Grid.Row="0" Grid.Column="1" Scroll="Auto" Margin="5,0,0,0"
                          Content="{Binding Source={StaticResource SlimTvClient},Path=CurrentProgram.StartTime, Converter={StaticResource SlimTvDateFormatConverter}}"
                          Color="{ThemeResource TextColor}"/>

                      <Label Grid.Row="0" Grid.Column="2" Content="-" Color="{ThemeResource TextColor}"/>

                      <Label x:Name="ProgramEnd" Grid.Row="0" Grid.Column="3" Scroll="Auto" Margin="5,0,0,0"
                          Content="{Binding Source={StaticResource SlimTvClient},Path=CurrentProgram.EndTime, Converter={StaticResource SlimTvDateFormatConverter}}"
                          Color="{ThemeResource TextColor}"/>

                      <Label x:Name="Genre" Grid.Row="0" Grid.Column="4" Scroll="Auto" Margin="5,0,0,0"
                          Content="{Binding Source={StaticResource SlimTvClient},Path=CurrentProgram.Genre}"
                          Color="{ThemeResource TextColor}"/>

                      <Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="5" x:Name="Description" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                          Wrap="True" Scroll="Auto"
                          Height="{ThemeResource OSDDetailLabelHeight}"
                          Content="{Binding Source={StaticResource SlimTvClient},Path=CurrentProgram.Description}"
                          Color="{ThemeResource TextColor}"/>
                    </Grid>

                    <!-- Next Program detailed information -->
                    <Grid Grid.Column="0" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                        IsVisible="{Binding Source={StaticResource SlimTvClient},Path=IsOSDLevel2}">
                      <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                      </Grid.RowDefinitions>
                      <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="300"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="15"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                      </Grid.ColumnDefinitions>
                      <Label x:Name="NextChannel" Grid.Row="0" Grid.Column="0" Scroll="Auto" 
                          Content="{Binding Source={StaticResource SlimTvClient},Path=ChannelName}"
                          Color="{ThemeResource TextColor}"/>

                      <Label x:Name="NextProgramStart" Grid.Row="0" Grid.Column="1" Scroll="Auto" Margin="5,0,0,0"
                          Content="{Binding Source={StaticResource SlimTvClient},Path=NextProgram.StartTime, Converter={StaticResource SlimTvDateFormatConverter}}"
                          Color="{ThemeResource TextColor}"/>

                      <Label Grid.Row="0" Grid.Column="2" Content="-" Color="{ThemeResource TextColor}"/>

                      <Label x:Name="NextProgramEnd" Grid.Row="0" Grid.Column="3" Scroll="Auto" Margin="5,0,0,0"
                          Content="{Binding Source={StaticResource SlimTvClient},Path=NextProgram.EndTime, Converter={StaticResource SlimTvDateFormatConverter}}"
                          Color="{ThemeResource TextColor}"/>

                      <Label x:Name="NextGenre" Grid.Row="0" Grid.Column="4" Scroll="Auto" Margin="5,0,0,0" 
                          Content="{Binding Source={StaticResource SlimTvClient},Path=NextProgram.Genre}"
                          Color="{ThemeResource TextColor}"/>

                      <Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="5" x:Name="NextDescription" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                          Wrap="True" Scroll="Auto"
                          Height="{ThemeResource OSDDetailLabelHeight}"
                          Content="{Binding Source={StaticResource SlimTvClient},Path=NextProgram.Description}"
                          Color="{ThemeResource TextColor}"/>
                    </Grid>

                    <!--<Label x:Name="TimeLabel" Color="{ThemeResource TextColor}" FontSize="{ThemeResource BigFontSize}"
                        HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="2" Grid.Row="0" Grid.RowSpan="2" 
                        Content="{Binding Source={StaticResource TimeModel}, Path=CurrentTime}" />-->

                  </Grid>
                </DockPanel>
              </ControlTemplate>

              <ControlTemplate x:Key="OSD_Progress_Template">

                <DockPanel LastChildFill="true" Margin="10,5,15,5">
                  <Grid DockPanel.Dock="Center" HorizontalAlignment="Stretch">
                    <Grid.ColumnDefinitions>
                      <ColumnDefinition Width="Auto"/>
                      <ColumnDefinition Width="*"/>
                      <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                      <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>

                    <Label x:Name="CurrentProgramStartLabel" Grid.Column="0" 
                        Content="{Binding Source={StaticResource SlimTvClient}, Path=CurrentProgram.StartTime, Converter={StaticResource SlimTvDateFormatConverter}}"
                        Color="{ThemeResource TextColor}" HorizontalAlignment="Left" VerticalAlignment="Center"
                        FontSize="{ThemeResource SmallFontSize}"/>

                    <ProgressBar x:Name="CurrentProgramProgress" Grid.Column="1" Height="10" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="5,0,5,0"
                        Style="{ThemeResource OSDProgressBarStyle}" Value="{Binding Source={StaticResource SlimTvClient},Path=ProgramProgress}" />

                    <Label x:Name="CurrentProgramEndLabel" Grid.Column="2"
                        Content="{Binding Source={StaticResource SlimTvClient},Path=CurrentProgram.EndTime, Converter={StaticResource SlimTvDateFormatConverter}}"
                        Color="{ThemeResource TextColor}" HorizontalAlignment="Left" VerticalAlignment="Center"
                        FontSize="{ThemeResource SmallFontSize}"/>

                  </Grid>
                </DockPanel>
              </ControlTemplate>

              <ControlTemplate x:Key="OSD_Controls_Template">
                <Grid HorizontalAlignment="Stretch">
                  <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                  </Grid.ColumnDefinitions>
                  <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                  </Grid.RowDefinitions>
                  <StackPanel x:Name="PlayControlsPanel" Orientation="Horizontal" Grid.Column="0"
                              VerticalAlignment="Center" HorizontalAlignment="Center" >
                    <Button x:Name="SkipBackButton" Style="{ThemeResource SkipBackButtonStyle}" IsVisible="{Binding CanSkipBack}"
                            Command="{Command Previous}"/>
                    <Button x:Name="RewindButton" Style="{ThemeResource RewindButtonStyle}" IsVisible="{Binding CanSeekBackward}"
                            Command="{Command SeekBackward}"/>
                    <Button x:Name="PlayButton" Style="{ThemeResource PlayButtonStyle}" IsVisible="{Binding CanPlay}"
                            Command="{Command Play}"/>
                    <Button x:Name="PauseButton" Style="{ThemeResource PauseButtonStyle}" IsVisible="{Binding CanPause}"
                            Command="{Command Pause}"/>
                    <Button x:Name="StopButton" Style="{ThemeResource StopButtonStyle}" IsVisible="{Binding CanStop}"
                            Command="{Command Stop}"/>
                    <Button x:Name="ForwardButton" Style="{ThemeResource ForwardButtonStyle}" IsVisible="{Binding CanSeekForward}"
                            Command="{Command SeekForward}"/>
                    <Button x:Name="SkipForwardButton" Style="{ThemeResource SkipForwardButtonStyle}" IsVisible="{Binding CanSkipForward}"
                            Command="{Command Next}"/>
                    <Image Source="topbar_devider.png" Margin="15,0,15,0"/>                                         
                    <Button x:Name="SelectSubtitleButton" Style="{ThemeResource SelectSubtitleButtonStyle}" Margin="0,0,0,0"
                            IsVisible="{Binding Source={StaticResource VideoPlayerModel},Path=PlayerUIContributor.SubtitlesAvailable}"
                            Command="{Command Source={StaticResource VideoPlayerModel},Path=PlayerUIContributor.OpenChooseSubtitleDialog}"/>
                    <Button x:Name="Audio" Style="{ThemeResource AudioActiveButtonStyle}" Margin="0,0,0,0" IsVisible="{Binding IsAudio}"
                            Command="{Command AudioButtonPressed}"/>
                    <Image Source="topbar_devider.png" Margin="15,0,15,0"/>
                    <Button x:Name="BackButton" Style="{ThemeResource NavigateBackButtonStyle}" Margin="0,0,0,0"
                            Command="{Command Source={Service WorkflowManager},Path=NavigatePop,Parameters=1}"/>
                    <Button x:Name="PowerButton" Style="{ThemeResource PowerButtonStyle}" Margin="0,0,0,0"
                            Command="{Command Source={Service WorkflowManager},Path=NavigatePush,Parameters=BBFA7DB7-5055-48D5-A904-0F0C79849369}"/>
                  </StackPanel>
                </Grid>
              </ControlTemplate>

            </Control.Resources>
          </Control>

          <ControlTemplate.Triggers>
            <Trigger Property="IsCurrentPlayer" Value="True">
              <Trigger.EnterActions>
                <BeginStoryboard x:Name="CurrentPlayer_BeginStoryboard" Storyboard="{ThemeResource OSDCurrentPlayerControlStoryboard}"/>
              </Trigger.EnterActions>
              <Trigger.ExitActions>
                <StopStoryboard BeginStoryboardName="CurrentPlayer_BeginStoryboard"/>
              </Trigger.ExitActions>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="PlayerContext" Value="PrimaryPlayer"/>
  </Style>

  <!-- RecordingItem -->

  <ControlTemplate x:Key="GridViewRecordingItemTemplate">
    <Grid x:Name="ItemControl" Margin="8,3,0,3">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="{StaticResource MEDIA_VIDEO_WIDTH}"/>
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
        <RowDefinition Height="{StaticResource MEDIA_VIDEO_HEIGHT}"/>
      </Grid.RowDefinitions>
      <Image x:Name="thumb" Stretch="Uniform" Margin="2,0,2,0"
             Source="{Binding MediaItem}" Width="{StaticResource MEDIA_VIDEO_WIDTH}">
        <Image.OpacityMask >
          <ImageBrush ImageSource="video_thumb_mask.png"/>
        </Image.OpacityMask>
        <Image.Opacity>
          <MultiBinding Converter="{StaticResource ExpressionMultiValueConverter}" ConverterParameter="{}{0} ? {1} : {2}">
            <Binding RelativeSource="{RelativeSource Mode=FindAncestor,AncestorType={x:Type Button}}" Path="HasFocus"/>
            <Binding Source="1.0"/>
            <Binding Source="0.85"/>
          </MultiBinding>
        </Image.Opacity>
      </Image>
      <Image Stretch="Fill" Margin="0" IsVisible="{Binding ElementName=thumb, Path=!HasImage}"
             Source="tvseries_thumb_background.png" Opacity="0.85">
      </Image>
      <Image Stretch="Uniform" Margin="25" IsVisible="{Binding ElementName=thumb, Path=!HasImage}"
             Source="defaultVideo.png" >
        <Image.Opacity>
          <MultiBinding Converter="{StaticResource ExpressionMultiValueConverter}" ConverterParameter="{}{0} ? {1} : {2}">
            <Binding RelativeSource="{RelativeSource Mode=FindAncestor,AncestorType={x:Type Button}}" Path="HasFocus"/>
            <Binding Source="1.0"/>
            <Binding Source="0.85"/>
          </MultiBinding>
        </Image.Opacity>
      </Image>
      <Image Source="episode_thumb_focus.png" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Fill"
             Width="{StaticResource MEDIA_VIDEO_WIDTH}" Margin="-8,-2,-6,-2"
             IsVisible="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Button}},Path=HasFocus}">
      </Image>
      <!-- Unwatched indicator -->
      <Image Source="unwatched_flag.png" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2">
        <Image.IsVisible>
          <Binding Path="PlayCount" Converter="{StaticResource ExpressionValueConverter}" ConverterParameter="{}{0} == 0"/>
        </Image.IsVisible>
      </Image>
    </Grid>
  </ControlTemplate>
  
  <ControlTemplate x:Key="ListViewRecordingItemTemplate">
    <Grid x:Name="ItemControl">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto"/>
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
      </Grid.RowDefinitions>
      <DockPanel LastChildFill="True" Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Margin="0,3,4,3">
        <Image x:Name="ItemTypeSmall" Stretch="Uniform"
            Source="{Binding MediaItem}" FallbackSource="defaultVideo.png" Width="{StaticResource MEDIA_THUMB_WIDTH_S}" Height="{StaticResource MEDIA_THUMB_HEIGHT_S}">
          <Image.IsVisible>
            <Binding Source="{StaticResource ViewModeModel}" Path="LayoutSize" Converter="{StaticResource ExpressionValueConverter}" ConverterParameter="{}{0} == {LayoutSize}.{Small}"/>
          </Image.IsVisible>
        </Image>
        <Image x:Name="ItemTypeMedium" Stretch="Uniform"
            Source="{Binding MediaItem}" FallbackSource="defaultVideo.png" Width="{StaticResource MEDIA_THUMB_WIDTH_M}" Height="{StaticResource MEDIA_THUMB_HEIGHT_M}">
          <Image.IsVisible>
            <Binding Source="{StaticResource ViewModeModel}" Path="LayoutSize" Converter="{StaticResource ExpressionValueConverter}" ConverterParameter="{}{0} == {LayoutSize}.{Medium}"/>
          </Image.IsVisible>
        </Image>
        <Image x:Name="ItemTypeLarge" Stretch="Uniform"
            Source="{Binding MediaItem}" FallbackSource="defaultVideo.png" Width="{StaticResource MEDIA_THUMB_WIDTH_L}" Height="{StaticResource MEDIA_THUMB_HEIGHT_L}">
          <Image.IsVisible>
            <Binding Source="{StaticResource ViewModeModel}" Path="LayoutSize" Converter="{StaticResource ExpressionValueConverter}" ConverterParameter="{}{0} == {LayoutSize}.{Large}"/>
          </Image.IsVisible>
        </Image>
      </DockPanel>
      <Label x:Name="ItemLabel" Grid.Row="0" Grid.Column="1" Content="{Binding SimpleTitle}" FontSize="{ThemeResource SmallFontSize}">
        <Label.Color>
          <MultiBinding Converter="{StaticResource ExpressionMultiValueConverter}" ConverterParameter="{}{0} == 0 ? {1} : {2}">
            <Binding Path="PlayCount"/>
            <Binding Source="{ThemeResource TextColor}"/>
            <Binding Source="{ThemeResource WatchedTextColor}"/>
          </MultiBinding>
        </Label.Color>
      </Label>
      <Label x:Name="Duration" Grid.Row="0" Grid.Column="2" Content="{Binding Duration}" Margin="0,0,15,0"
          Color="{ThemeResource TextColor}" FontSize="{ThemeResource SmallFontSize}"/>
      <Grid x:Name="Details" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" Margin="0,0,15,0">
        <Grid.IsVisible>
          <Binding Source="{StaticResource ViewModeModel}" Path="LayoutSize" Converter="{StaticResource ExpressionValueConverter}" ConverterParameter="{}{0} != {LayoutSize}.{Small}"/>
        </Grid.IsVisible>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto"/>
          <ColumnDefinition Width="200"/>
          <ColumnDefinition Width="Auto"/>
          <ColumnDefinition Width="200"/>
        </Grid.ColumnDefinitions>
        <Label x:Name="VideoEncodingTitle" Grid.Column="0" Content="Video: " FontSize="{ThemeResource SmallFontSize}" Color="{StaticResource MediaDetailsColor}"/>
        <Label x:Name="VideoEncoding" Grid.Column="1" Content="{Binding VideoEncoding}" FontSize="{ThemeResource SmallFontSize}" Color="{StaticResource MediaDetailsColor}"/>
        <Label x:Name="AudioEncodingTitle" Grid.Column="2" Content="Audio: " FontSize="{ThemeResource SmallFontSize}" Color="{StaticResource MediaDetailsColor}"/>
        <Label x:Name="AudioEncoding" Grid.Column="3" Content="{Binding AudioEncoding}" FontSize="{ThemeResource SmallFontSize}" Color="{StaticResource MediaDetailsColor}"/>
      </Grid>
    </Grid>
  </ControlTemplate>
  
  <DataTemplate DataType="{x:Type navitems:RecordingItem}">
    <Control>
      <Control.Template>
        <MultiBinding Converter="{StaticResource ExpressionMultiValueConverter}" ConverterParameter="{}{0} == {LayoutType}.{ListLayout} ? {1} : ({0} == {LayoutType}.{GridLayout} ? {2} : {3})">
          <Binding Source="{StaticResource ViewModeModel}" Path="LayoutType"/>
          <Binding Source="{StaticResource ListViewRecordingItemTemplate}"/>
          <Binding Source="{StaticResource GridViewRecordingItemTemplate}"/>
          <Binding Source=""/>
        </MultiBinding>
      </Control.Template>
    </Control>
  </DataTemplate>


  <Style x:Key="ProgramGuideButtonControlStyle" TargetType="{x:Type Control}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate>
          <DockPanel Name="ButtonControlRectangle">
            <Rectangle DockPanel.Dock="Center" RadiusX="0" RadiusY="0" Name="ButtonBase" Fill="{ThemeResource ProgramBaseFill}" Stroke="Transparent"/>
            <Rectangle DockPanel.Dock="Center" Name="ButtonHover" Fill=""/>
            <Rectangle DockPanel.Dock="Center" Name="ButtonOverlay" Fill=""/>
          </DockPanel>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <!--
  ProgramGuideButtonStyle is used as style for a single Program in MultiChannelGuide
  It's basically the DefaultButtonStyle without the Margin for ButtonControlStyle, 
  which would lead to incorrect Layout for short Programs (minimum Width).
  -->
  <Style x:Key="ProgramGuideButtonStyle" TargetType="{x:Type Button}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate>
          <Grid x:Name="GrowControl" RenderTransformOrigin="0.5,0.5" Margin="2,2,2,2">
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="*"/>
              <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
              <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.RenderTransform>
              <TransformGroup>
                <ScaleTransform ScaleX="1" ScaleY="1"/>
              </TransformGroup>
            </Grid.RenderTransform>
            <Control Grid.ColumnSpan="2" Style="{ThemeResource ProgramGuideButtonControlStyle}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
            <ContentPresenter Grid.ColumnSpan="2" x:Name="ButtonContentPresenter" Margin="3,5,0,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
            <Image Grid.Column="1" x:Name="SeriesRecIndicator" Source="tvguide_recordserie_button.png" IsVisible="False"
                   Height="{ThemeResource SeriesRecIndicatorHeight}" Stretch="Uniform"/>
          </Grid>
          <ControlTemplate.Triggers>
            <!-- Handling of different program states -->
            <DataTrigger Binding="{Binding IsRunning}" Value="True">
              <Setter TargetName="ButtonBase" Property="Fill" Value="{ThemeResource ProgramRunningFill}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Program.IsScheduled}" Value="True">
              <Setter TargetName="ButtonOverlay" Property="Fill" Value="{ThemeResource ProgramScheduledFill}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Program.IsSeriesScheduled}" Value="True">
              <Setter TargetName="SeriesRecIndicator" Property="IsVisible" Value="True"/>
            </DataTrigger>
            <Trigger Property="HasFocus" Value="True">
              <Setter TargetName="ButtonHover" Property="Fill" Value="{ThemeResource ProgramFocusedFill}"/>
            </Trigger>

          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="TVButton3Style" TargetType="{x:Type Button}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate>
          <Grid x:Name="GrowControl" RenderTransformOrigin="0.5,0.5" Margin="2">
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
              <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.RenderTransform>
              <TransformGroup>
                <ScaleTransform ScaleX="1" ScaleY="1"/>
              </TransformGroup>
            </Grid.RenderTransform>
            <!--Control x:Name="ButtonControlBackground" Style="{ThemeResource ProgramGuideButtonControlStyle}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/-->
            <ContentPresenter x:Name="ButtonContentPresenter" Margin="10,5,10,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
          </Grid>
          <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding IsRunning}" Value="True">
              <Setter TargetName="Item1" Property="Background" Value="{ThemeResource ProgramRunningFill}"/>
              <Setter TargetName="Item2" Property="Background" Value="{ThemeResource ProgramRunningFill}"/>
              <Setter TargetName="Item3" Property="Background" Value="{ThemeResource ProgramRunningFill}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Program.IsScheduled}" Value="True">
              <Setter TargetName="Item2_record" Property="Background" Value="{ThemeResource ProgramScheduledFill}"/>
              <Setter TargetName="Item3_record" Property="Background" Value="{ThemeResource ProgramRecordFill}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Program.IsSeriesScheduled}" Value="True">
              <Setter TargetName="SeriesRecIndicator" Property="IsVisible" Value="True"/>
            </DataTrigger>
            <!--Trigger Property="HasFocus" Value="False">
              <Setter TargetName="Item1_overlay" Property="Background" Value="{ThemeResource ProgramBaseFill}"/>
              <Setter TargetName="Item2_overlay" Property="Background" Value="{ThemeResource ProgramBaseFill}"/>
              <Setter TargetName="Item3_overlay" Property="Background" Value="{ThemeResource ProgramBaseFill}"/>
            </Trigger-->            
            <Trigger Property="HasFocus" Value="True">
              <Setter TargetName="Item1_overlay" Property="Background" Value="{ThemeResource ProgramFocusedFill}"/>
              <Setter TargetName="Item2_overlay" Property="Background" Value="{ThemeResource ProgramFocusedFill}"/>
              <Setter TargetName="Item3_overlay" Property="Background" Value="{ThemeResource ProgramFocusedFill}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="TVButton4Style" TargetType="{x:Type Button}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate>
          <Grid x:Name="GrowControl" RenderTransformOrigin="0.5,0.5" Margin="2">
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
              <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.RenderTransform>
              <TransformGroup>
                <ScaleTransform ScaleX="1" ScaleY="1"/>
              </TransformGroup>
            </Grid.RenderTransform>
            <!--Control x:Name="ButtonControlBackground" Style="{ThemeResource ProgramGuideButtonControlStyle}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/-->
            <ContentPresenter x:Name="ButtonContentPresenter" Margin="10,5,10,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
          </Grid>
          <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding IsRunning}" Value="True">
              <Setter TargetName="Item1" Property="Background" Value="{ThemeResource ProgramRunningFill}"/>
              <Setter TargetName="Item2" Property="Background" Value="{ThemeResource ProgramRunningFill}"/>
              <Setter TargetName="Item3" Property="Background" Value="{ThemeResource ProgramRunningFill}"/>
              <Setter TargetName="Item4" Property="Background" Value="{ThemeResource ProgramRunningFill}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Program.IsScheduled}" Value="True">
              <Setter TargetName="Item3_record" Property="Background" Value="{ThemeResource ProgramScheduledFill}"/>
              <Setter TargetName="Item4_record" Property="Background" Value="{ThemeResource ProgramRecordFill}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Program.IsSeriesScheduled}" Value="True">
              <Setter TargetName="SeriesRecIndicator" Property="IsVisible" Value="True"/>
            </DataTrigger>
            <!--Trigger Property="HasFocus" Value="False">
              <Setter TargetName="Item1_overlay" Property="Background" Value="{ThemeResource ProgramBaseFill}"/>
              <Setter TargetName="Item2_overlay" Property="Background" Value="{ThemeResource ProgramBaseFill}"/>
              <Setter TargetName="Item3_overlay" Property="Background" Value="{ThemeResource ProgramBaseFill}"/>
            </Trigger-->
            <Trigger Property="HasFocus" Value="True">
              <Setter TargetName="Item1_overlay" Property="Background" Value="{ThemeResource ProgramFocusedFill}"/>
              <Setter TargetName="Item2_overlay" Property="Background" Value="{ThemeResource ProgramFocusedFill}"/>
              <Setter TargetName="Item3_overlay" Property="Background" Value="{ThemeResource ProgramFocusedFill}"/>
              <Setter TargetName="Item4_overlay" Property="Background" Value="{ThemeResource ProgramFocusedFill}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <DataTemplate x:Key="ChannelWithCurrentProgramDataTemplate" DataType="{x:Type collections:ListItem}">
    <Grid x:Name="ItemControl" VerticalAlignment="Center" HorizontalAlignment="Stretch" RenderTransformOrigin="0.5,0.5"
          Margin="-80,0,0,0">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <!-- Channel Logo -->
        <ColumnDefinition Width="400"/>
        <!-- Channel Name -->
        <ColumnDefinition Width="*"/>
        <!-- Program Title -->
        <ColumnDefinition Width="200"/>
        <!-- Program Time -->
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
      </Grid.RowDefinitions>
      <Grid.RenderTransform>
        <TransformGroup>
          <ScaleTransform ScaleX="1" ScaleY="1"/>
        </TransformGroup>
      </Grid.RenderTransform>

      <Border x:Name="Item1" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="{ThemeResource ProgramBaseFill}" BorderThickness="0" Margin="0,-5,5,-5"/>
      <Border x:Name="Item2" Grid.Row="0" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="{ThemeResource ProgramBaseFill}" BorderThickness="0" Margin="0,-5,15,-5"/>
      <Border x:Name="Item3" Grid.Row="0" Grid.Column="3" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="{ThemeResource ProgramBaseFill}" BorderThickness="0" Margin="-10,-5,-15,-5"/>

      <Border x:Name="Item2_record" Grid.Row="0" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="0,-5,15,-5"/>
      <Border x:Name="Item3_record" Grid.Row="0" Grid.Column="3" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="-10,-5,-15,-5"/>

      <Border x:Name="Item1_overlay" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="0,-5,5,-5"/>
      <Border x:Name="Item2_overlay" Grid.Row="0" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="0,-5,15,-5"/>
      <Border x:Name="Item3_overlay" Grid.Row="0" Grid.Column="3" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="-10,-5,-15,-5"/>

      <Label Grid.Column="1" Grid.Row="0" x:Name="NameLabel" Margin="3,5,0,5" Content="{Binding [Name]}" Color="{ThemeResource TextColor}"
       VerticalAlignment="Center" FontSize="{ThemeResource SmallFontSize}"/>

      <Image x:Name="ChannelLogo" Grid.Column="0" Grid.Row="0" Width="{ThemeResource ChannelLogoMedium}" Stretch="Uniform" Margin="10,0,10,0" VerticalAlignment="Center">
        <Image.Source>
          <fanart:FanArtImageSource fanart:FanArtMediaType="ChannelTv" fanart:FanArtType="Banner" fanart:FanArtName="{Binding ChannelLogoPath}" fanart:MaxWidth="0" fanart:MaxHeight="0"/>
        </Image.Source>
      </Image>

      <Label Grid.Column="2" Grid.Row="0" x:Name="CurrentProgramLabel" Margin="5,5,20,5"
        Content="{Binding Programs[0].Program.Title}" FontSize="{ThemeResource SmallFontSize}"
        Color="{ThemeResource TextColor}"/>

      <!-- Shows the progress of current time in relation to the current playing program -->
      <ProgressBar x:Name="CurrentProgramProgress" Grid.Column="3" Grid.Row="0" Height="16" HorizontalAlignment="Stretch" VerticalAlignment="Center"
                    Value="{Binding Programs[0].Progress}"/>
    </Grid>
  </DataTemplate>

  <DataTemplate x:Key="SingleChannelWithCurrentProgramDataTemplate" DataType="{x:Type collections:ListItem}">
    <Grid x:Name="ItemControl" VerticalAlignment="Center" HorizontalAlignment="Stretch" RenderTransformOrigin="0.5,0.5"
          Margin="-80,0,0,0">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <!-- Channel Logo -->
        <ColumnDefinition Width="300"/>
        <!-- Channel Name -->
        <ColumnDefinition Width="*"/>
        <!-- Program Title -->
        <ColumnDefinition Width="250"/>
        <!-- Program Time -->
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
      </Grid.RowDefinitions>
      <Grid.RenderTransform>
        <TransformGroup>
          <ScaleTransform ScaleX="1" ScaleY="1"/>
        </TransformGroup>
      </Grid.RenderTransform>

      <Border x:Name="Item1" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="{ThemeResource ProgramBaseFill}" BorderThickness="0" Margin="0,-5,5,-5"/>
      <Border x:Name="Item2" Grid.Row="0" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="{ThemeResource ProgramBaseFill}" BorderThickness="0" Margin="0,-5,15,-5"/>
      <Border x:Name="Item3" Grid.Row="0" Grid.Column="3" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="{ThemeResource ProgramBaseFill}" BorderThickness="0" Margin="-10,-5,-15,-5"/>

      <Border x:Name="Item2_record" Grid.Row="0" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="0,-5,15,-5"/>
      <Border x:Name="Item3_record" Grid.Row="0" Grid.Column="3" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="-10,-5,-15,-5"/>

      <Border x:Name="Item1_overlay" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="0,-5,5,-5"/>
      <Border x:Name="Item2_overlay" Grid.Row="0" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="0,-5,15,-5"/>
      <Border x:Name="Item3_overlay" Grid.Row="0" Grid.Column="3" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="-10,-5,-15,-5"/>
      
      <Image x:Name="ChannelLogo" Grid.Column="0" Grid.Row="0" Width="{ThemeResource ChannelLogoMedium}" Stretch="Uniform" Margin="10,0,10,0" VerticalAlignment="Center">
        <Image.Source>
          <fanart:FanArtImageSource fanart:FanArtMediaType="ChannelTv" fanart:FanArtType="Banner" fanart:FanArtName="{Binding Program.ChannelName}" fanart:MaxWidth="0" fanart:MaxHeight="0"/>
        </Image.Source>
      </Image>
      <Label Grid.Column="1" Grid.Row="0" x:Name="NameLabel" Margin="3,5,0,5" Content="{Binding Program.ChannelName}" Color="{ThemeResource TextColor}"
       VerticalAlignment="Center" FontSize="{ThemeResource SmallFontSize}"/>
      
      <Label Grid.Column="2" Grid.Row="0" x:Name="CurrentProgramLabel" Margin="5,5,20,5"
        Content="{Binding [Title]}" FontSize="{ThemeResource SmallFontSize}"
        Color="{ThemeResource TextColor}"/>
      
      <Label Grid.Column="3" Grid.Row="0" x:Name="ProgramLabel" Margin="5,5,0,5" VerticalAlignment="Center"
        Content="{Binding [StartTime]}" FontSize="{ThemeResource SmallFontSize}"
        Color="{ThemeResource TextColor}"/>
      
    </Grid>
  </DataTemplate>

  <Style x:Key="TVListViewStyle" TargetType="{x:Type ListView}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ListView}">
          <ScrollViewer CanContentScroll="True" Margin="0,0,-17,0" >
            <ItemsPresenter VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0,0,30,0"/>
          </ScrollViewer>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="ItemsPanel">
      <Setter.Value>
        <ItemsPanelTemplate>
          <StackPanel x:Name="ListItemsHost" IsItemsHost="True" LoopScroll="True"/>
        </ItemsPanelTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <!--Style x:Key="TVItemContainerStyle" TargetType="{x:Type ListViewItem}">
    <Style.Triggers>
      <Trigger Property="Selected" Value="True">
        <Setter Property="StackPanel.ZIndex" Value="100.0"/>
      </Trigger>
    </Style.Triggers>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ListViewItem}">
          <Button Margin="10,0,10,0" Style="{ThemeResource ButtonMediaItemStyle}"
                  Command="{DynamicResource ResourceKey=Menu_Command}"
                  IsEnabled="{Binding Enabled}" SetFocus="{Binding Path=Selected,Mode=OneTime}">
            <Button.Triggers>
              <Trigger Property="HasFocus" Value="True">
                <Setter TargetName="ButtonControlRectangle" Property="IsVisible" Value="True"/>
              </Trigger>
            </Button.Triggers>
          </Button>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style-->

  <Style x:Key="TVItemContainerMainStyle" TargetType="{x:Type ListViewItem}">
    <Style.Triggers>
      <Trigger Property="Selected" Value="True">
        <!-- Hack: It is sufficient to set the attached ZIndex property for one panel type; the MP2 SkinEngine maps it to the
             same internal property for all panel types -->
        <Setter Property="StackPanel.ZIndex" Value="100.0"/>
      </Trigger>
    </Style.Triggers>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ListViewItem}">
          <Button Margin="50,0,20,0" Style="{ThemeResource TVButton3Style}"
                  Command="{DynamicResource ResourceKey=Menu_Command}"
                  IsEnabled="{Binding Enabled}" SetFocus="{Binding Path=Selected,Mode=OneTime}">
            <!--Button.Triggers>
              <Trigger Property="HasFocus" Value="True">
                <Setter TargetName="Item1" Property="Background" Value="#003366"/>
                <Setter TargetName="Item2" Property="Background" Value="#003366"/>
                <Setter TargetName="Item3" Property="Background" Value="#003366"/>
              </Trigger>
            </Button.Triggers-->
          </Button>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <DataTemplate x:Key="SearchProgramDataTemplate" DataType="{x:Type collections:ListItem}">
    <Grid x:Name="ItemControl" VerticalAlignment="Center" HorizontalAlignment="Stretch" RenderTransformOrigin="0.5,0.5"
          Margin="-80,0,0,0">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <!-- Channel Logo -->
        <ColumnDefinition Width="250"/>
        <!-- Channel Name -->
        <ColumnDefinition Width="*"/>
        <!-- Program Title -->
        <ColumnDefinition Width="240"/>
        <!-- Program Time -->
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
      </Grid.RowDefinitions>
      <Grid.RenderTransform>
        <TransformGroup>
          <ScaleTransform ScaleX="1" ScaleY="1"/>
        </TransformGroup>
      </Grid.RenderTransform>

      <Image Grid.Column="2" x:Name="SeriesRecIndicator" Source="tvguide_recordserie_button.png" IsVisible="False"
       Height="{ThemeResource SeriesRecIndicatorHeight}" Stretch="Uniform" HorizontalAlignment="Right"/>

      <Border x:Name="Item1" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="{ThemeResource ProgramBaseFill}" BorderThickness="0" Margin="0,-5,5,-5"/>
      <Border x:Name="Item2" Grid.Row="0" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="{ThemeResource ProgramBaseFill}" BorderThickness="0" Margin="0,-5,15,-5"/>
      <Border x:Name="Item3" Grid.Row="0" Grid.Column="3" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="{ThemeResource ProgramBaseFill}" BorderThickness="0" Margin="-10,-5,-15,-5"/>

      <Border x:Name="Item2_record" Grid.Row="0" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="0,-5,15,-5"/>
      <Border x:Name="Item3_record" Grid.Row="0" Grid.Column="3" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="-10,-5,-15,-5"/>

      <Border x:Name="Item1_overlay" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="0,-5,5,-5"/>
      <Border x:Name="Item2_overlay" Grid.Row="0" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="0,-5,15,-5"/>
      <Border x:Name="Item3_overlay" Grid.Row="0" Grid.Column="3" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="-10,-5,-15,-5"/>

      <Label Grid.Column="1" Grid.Row="0" x:Name="NameLabel" Margin="3,5,20,5" Content="{Binding Program.ChannelName}" Color="{ThemeResource TextColor}"
       VerticalAlignment="Center" FontSize="{ThemeResource SmallFontSize}"/>

      <Image x:Name="ChannelLogo" Grid.Column="0" Grid.Row="0" Width="{ThemeResource ChannelLogoMedium}" Stretch="Uniform" Margin="10,0,10,0" VerticalAlignment="Center">
        <Image.Source>
          <fanart:FanArtImageSource fanart:FanArtMediaType="ChannelTv" fanart:FanArtType="Banner" fanart:FanArtName="{Binding Program.ChannelName}" fanart:MaxWidth="0" fanart:MaxHeight="0"/>
        </Image.Source>
      </Image>

      <Label Grid.Column="2" Grid.Row="0" x:Name="CurrentProgramLabel" Margin="5,5,20,5"
        Content="{Binding [Name]}" FontSize="{ThemeResource SmallFontSize}"
        Color="{ThemeResource TextColor}"/>

      <StackPanel Orientation="Horizontal"  Grid.Column="3" Grid.Row="0" Margin="5,5,15,5">
        <Label x:Name="ProgramStart" Margin="0,0,0,0"  Color="{ThemeResource TextColor}" FontSize="{ThemeResource SmallFontSize}"
               Content="{Binding [StartTime]}"/>
        <!--Label Margin="5,0,5,0" Content="—" Color="{ThemeResource TextColor}" FontSize="{ThemeResource SmallFontSize}"/>
        <Label x:Name="ProgramEnd" Content="{Binding [EndTime]}" FontSize="{ThemeResource SmallFontSize}"
            Color="{ThemeResource TextColor}"/-->
      </StackPanel>

    </Grid>
  </DataTemplate>

  <Style x:Key="SearchProgramListViewStyle" BasedOn="{ThemeResource TVListViewStyle}">
    <Setter Property="ItemTemplate" Value="{ThemeResource SearchProgramDataTemplate}"/>
    <Setter Property="ItemContainerStyle" Value="{ThemeResource TVItemContainerMainStyle}"/>
  </Style>

  <Style x:Key="ChannelWithLogoAndProgramListViewStyle" BasedOn="{ThemeResource TVListViewStyle}">
    <Setter Property="ItemTemplate" Value="{ThemeResource ChannelWithCurrentProgramDataTemplate}"/>
    <Setter Property="ItemContainerStyle" Value="{ThemeResource TVItemContainerMainStyle}"/>
  </Style>

  <Style x:Key="SingleChannelWithLogoAndProgramListViewStyle" BasedOn="{ThemeResource TVListViewStyle}">
    <Setter Property="ItemTemplate" Value="{ThemeResource SingleChannelWithCurrentProgramDataTemplate}"/>
    <Setter Property="ItemContainerStyle" Value="{ThemeResource TVItemContainerMainStyle}"/>
  </Style>
  
  <!-- Style definition for EpgGrid defining header and program item styles -->
  <Style x:Key="EpgGridStyle" TargetType="{x:Type tv:EpgGrid}">
    <Setter Property="HeaderWidth" Value="{ThemeResource MultiGuideHeaderWidth}" />
    <Setter Property="HeaderTemplate">
      <Setter.Value>
        <ControlTemplate>
          <Button Style="{ThemeResource ProgramGuideButtonStyle}" Command="{Binding Command}" Margin="0,0,18,0">
            <Grid x:Name="ChannelHeader" RenderTransformOrigin="0.5,0.5" Margin="0,2,0,2">
              <Grid.ColumnDefinitions>
                <!-- Channel Name -->
                <ColumnDefinition Width="{ThemeResource ChannelLogoSmall}"/>
                <!-- Channel Logo -->
                <ColumnDefinition Width="*"/>
              </Grid.ColumnDefinitions>
              <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
              </Grid.RowDefinitions>
              <Grid.RenderTransform>
                <TransformGroup>
                  <ScaleTransform ScaleX="1" ScaleY="1"/>
                </TransformGroup>
              </Grid.RenderTransform>

              <Image x:Name="ChannelLogo" Grid.Column="0" Grid.Row="0" Width="{ThemeResource ChannelLogoSmall}" Height="{ThemeResource ChannelLogoSmall}" Stretch="Uniform"
                     Margin="10,0,10,0">
                <Image.Source>
                  <fanart:FanArtImageSource fanart:FanArtMediaType="ChannelTv" fanart:FanArtType="Banner" fanart:FanArtName="{Binding ChannelLogoPath}" fanart:MaxWidth="0" fanart:MaxHeight="0"/>
                </Image.Source>
              </Image>

              <Label Grid.Column="1" Grid.Row="0" x:Name="NameLabel" VerticalAlignment="Center"
                     Content="{Binding [Name]}" Color="{ThemeResource TextColor}" FontSize="{ThemeResource SmallFontSize}"/>

            </Grid>
          </Button>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="ProgramTemplate">
      <Setter.Value>
        <ControlTemplate>
          <Button
              Style="{ThemeResource ProgramGuideButtonStyle}"
              IsEnabled="{Binding Enabled}"
              SetFocus="{Binding Path=Selected,Mode=OneTime}"
              Command="{Binding Command}"
              >
            <Button.Triggers>
              <Trigger Property="HasFocus" Value="True">
                <Setter TargetName="ItemLabel" Property="Scroll" Value="Auto"/>
                <Trigger.EnterActions>
                  <TriggerCommand>
                    <TriggerCommand.Command>
                      <Command x:Key="SelectionChanged_Command"
                                 Source="{StaticResource SlimTvMultiChannelGuide}"
                                 Path="UpdateProgram"
                                 Parameters="{LateBoundValue BindingValue={Binding}}" />
                    </TriggerCommand.Command>
                  </TriggerCommand>
                </Trigger.EnterActions>
              </Trigger>
            </Button.Triggers>

            <Grid>
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
              </Grid.ColumnDefinitions>
              <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
              </Grid.RowDefinitions>

              <Label x:Name="ItemLabel" Content="{Binding [Name]}" VerticalAlignment="Center" Color="{ThemeResource TextColor}" FontSize="{ThemeResource SmallFontSize}"
                     Margin="2,0,0,0"
                     FontFamily="DefaultBold"/>

              <Label x:Name="SeriesLabel" Grid.Column="1" Content="{Binding [Series]}" VerticalAlignment="Center" Color="{ThemeResource TextColor}" FontSize="{ThemeResource SmallFontSize}"
                     Margin="10,0,0,0"
                     FontFamily="Default"/>
            </Grid>
          </Button>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="TimeIndicatorTemplate">
      <Setter.Value>
        <ControlTemplate>
          <Rectangle x:Name="TimeIndicator" Width="4" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="0,0,10,0">
            <Rectangle.Fill>
              <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
                <GradientStop Offset="0" Color="#20A0A0A0"/>
                <GradientStop Offset="1"  Color="#A0F0F0F0"/>
              </LinearGradientBrush >
            </Rectangle.Fill>
          </Rectangle>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="ScheduleItemContainerStyle" TargetType="{x:Type ListViewItem}">
    <Style.Triggers>
      <Trigger Property="Selected" Value="True">
        <!-- Hack: It is sufficient to set the attached ZIndex property for one panel type; the MP2 SkinEngine maps it to the
             same internal property for all panel types -->
        <Setter Property="StackPanel.ZIndex" Value="100.0"/>
      </Trigger>
    </Style.Triggers>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ListViewItem}">
          <Button Margin="50,0,20,0" Style="{ThemeResource TVButton4Style}"
                  Command="{DynamicResource ResourceKey=Menu_Command}"
                  IsEnabled="{Binding Enabled}" SetFocus="{Binding Path=Selected,Mode=OneTime}">
            <!--Button.Triggers>
              <Trigger Property="HasFocus" Value="True">
                <Setter TargetName="Item1" Property="Background" Value="{ThemeResource ProgramFocusedFill}"/>
                <Setter TargetName="Item2" Property="Background" Value="{ThemeResource ProgramFocusedFill}"/>
                <Setter TargetName="Item3" Property="Background" Value="{ThemeResource ProgramFocusedFill}"/>
                <Setter TargetName="Item4" Property="Background" Value="{ThemeResource ProgramFocusedFill}"/>
              </Trigger>
            </Button.Triggers-->
          </Button>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="ExtScheduleItemContainerStyle" TargetType="{x:Type ListViewItem}">
    <Style.Triggers>
      <Trigger Property="Selected" Value="True">
        <!-- Hack: It is sufficient to set the attached ZIndex property for one panel type; the MP2 SkinEngine maps it to the
             same internal property for all panel types -->
        <Setter Property="StackPanel.ZIndex" Value="100.0"/>
      </Trigger>
    </Style.Triggers>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ListViewItem}">
          <Button Margin="0,0,0,0" Style="{ThemeResource TVButton3Style}"
                  Command="{DynamicResource ResourceKey=Menu_Command}"
                  IsEnabled="{Binding Enabled}" SetFocus="{Binding Path=Selected,Mode=OneTime}">
            <!--Button.Triggers>
              <Trigger Property="HasFocus" Value="True">
                <Setter TargetName="Item1" Property="Background" Value="#003366"/>
                <Setter TargetName="Item2" Property="Background" Value="#003366"/>
                <Setter TargetName="Item3" Property="Background" Value="#003366"/>
              </Trigger>
            </Button.Triggers-->
          </Button>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <!-- ScheduleDataTemplate contains channel logo, title, recording type -->
  <DataTemplate x:Key="ScheduleDataTemplate" DataType="{x:Type collections:ListItem}">
    <Grid x:Name="ItemControl" VerticalAlignment="Center" HorizontalAlignment="Stretch">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="320"/>
        <ColumnDefinition Width="430"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="220"/>
      </Grid.ColumnDefinitions>

      <Border x:Name="Item1" Grid.Row="0" Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="{ThemeResource ProgramBaseFill}" BorderThickness="0" Margin="0,-5,5,-5"/>
      <Border x:Name="Item2" Grid.Row="0" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="{ThemeResource ProgramBaseFill}" BorderThickness="0" Margin="0,-5,5,-5"/>
      <Border x:Name="Item3" Grid.Row="0" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="{ThemeResource ProgramBaseFill}" BorderThickness="0" Margin="0,-5,15,-5"/>
      <Border x:Name="Item4" Grid.Row="0" Grid.Column="3" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="{ThemeResource ProgramBaseFill}" BorderThickness="0" Margin="-10,-5,-15,-5"/>

      <Border x:Name="Item3_record" Grid.Row="0" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="0,-5,15,-5"/>
      <Border x:Name="Item4_record" Grid.Row="0" Grid.Column="3" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="-10,-5,-15,-5"/>

      <Border x:Name="Item1_overlay" Grid.Row="0" Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="0,-5,5,-5"/>
      <Border x:Name="Item2_overlay" Grid.Row="0" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="0,-5,5,-5"/>
      <Border x:Name="Item3_overlay" Grid.Row="0" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="0,-5,15,-5"/> 
      <Border x:Name="Item4_overlay" Grid.Row="0" Grid.Column="3" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
        Background="Transparent" BorderThickness="0" Margin="-10,-5,-15,-5"/>
      
      <StackPanel Orientation="Horizontal" Grid.Column="0" x:Name="Channel">
        <Image x:Name="ChannelLogo" Height="40" Stretch="Uniform" Margin="5,2,5,2">
          <Image.Source>
            <fanart:FanArtImageSource fanart:FanArtMediaType="ChannelTv" fanart:FanArtType="Banner" fanart:FanArtName="{Binding [ChannelName]}"
                                      fanart:MaxWidth="0" fanart:MaxHeight="0"/>
          </Image.Source>
        </Image>
        <Label x:Name="ChannelText" Scroll="Auto" Content="{Binding [ChannelName]}" Color="{ThemeResource TextColor}"
               FontSize="{ThemeResource SmallFontSize}" Margin="5,0,10,0" VerticalAlignment="Center" HorizontalAlignment="Stretch"/>
      </StackPanel>

      <Label x:Name="ItemLabel" Grid.Column="1" Content="{Binding [Name]}" Color="{ThemeResource TextColor}" Scroll="Auto"
             FontSize="{ThemeResource SmallFontSize}" Margin="10,0,10,0" VerticalAlignment="Center" HorizontalAlignment="Stretch"/>

      <Label x:Name="TypeLabel" Grid.Column="2" Content="{Binding [ScheduleType]}" VerticalAlignment="Center" Scroll="Auto"
             Color="{ThemeResource TextColor}" FontSize="{ThemeResource SmallFontSize}" Margin="10,0,20,0" HorizontalAlignment="Stretch" />

      <StackPanel Orientation="Horizontal" Grid.Column="3" >
        <Label x:Name="ProgramStart" Margin="10,0,10,0"  Color="{ThemeResource TextColor}" VerticalAlignment="Center"
               Content="{Binding [StartTime]}" FontSize="{ThemeResource SmallFontSize}"/>
      </StackPanel>
    </Grid>
  </DataTemplate>

  <DataTemplate x:Key="ExtScheduleItemDataTemplate" DataType="{x:Type collections:ListItem}">
    <Grid x:Name="ItemControl" VerticalAlignment="Center" HorizontalAlignment="Stretch">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="330"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="230"/>
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
      </Grid.RowDefinitions>

      <Border x:Name="Item1" Grid.Row="0" Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="{ThemeResource ProgramBaseFill}" BorderThickness="0" Margin="0,-5,2,-5"/>
      <Border x:Name="Item2" Grid.Row="0" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="{ThemeResource ProgramBaseFill}" BorderThickness="0" Margin="2,-5,2,-5"/>
      <Border x:Name="Item3" Grid.Row="0" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="{ThemeResource ProgramBaseFill}" BorderThickness="0" Margin="2,-5,5,-5"/>

      <Border x:Name="Item2_record" Grid.Row="0" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="2,-5,2,-5"/>
      <Border x:Name="Item3_record" Grid.Row="0" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="2,-5,5,-5"/>

      <Border x:Name="Item1_overlay" Grid.Row="0" Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="0,-5,2,-5"/>
      <Border x:Name="Item2_overlay" Grid.Row="0" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="2,-5,2,-5"/>
      <Border x:Name="Item3_overlay" Grid.Row="0" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              Background="Transparent" BorderThickness="0" Margin="2,-5,5,-5"/>

      <StackPanel Orientation="Horizontal" Grid.Column="0" x:Name="Channel">
        <Image x:Name="ChannelLogo" Height="40" Stretch="Uniform" Margin="5,2,5,2">
          <Image.Source>
            <fanart:FanArtImageSource fanart:FanArtMediaType="ChannelTv" fanart:FanArtType="Banner" fanart:FanArtName="{Binding [ChannelName]}"
                                      fanart:MaxWidth="0" fanart:MaxHeight="0"/>
          </Image.Source>
        </Image>
        <Label x:Name="ChannelText" Scroll="Auto" Content="{Binding [ChannelName]}" Color="{ThemeResource TextColor}"
               FontSize="{ThemeResource SmallFontSize}" Margin="5,0,10,0" VerticalAlignment="Center"/>
      </StackPanel>

      <Label x:Name="ItemLabel" Grid.Column="1" Content="{Binding [Name]}" Color="{ThemeResource TextColor}" Scroll="Auto"
             FontSize="{ThemeResource SmallFontSize}" Margin="10,0,10,0" VerticalAlignment="Center"/>

      <StackPanel Orientation="Horizontal" Grid.Column="2" >
        <Label x:Name="ProgramStart" Margin="10,0,10,0"  Color="{ThemeResource TextColor}" VerticalAlignment="Center"
               Content="{Binding [StartTime]}" FontSize="{ThemeResource SmallFontSize}"/>
      </StackPanel>
    </Grid>
  </DataTemplate>

  <Style x:Key="ScheduleListViewStyle" BasedOn="{ThemeResource TVListViewStyle}">
    <Setter Property="ItemTemplate" Value="{ThemeResource ScheduleDataTemplate}"/>
    <Setter Property="ItemContainerStyle" Value="{ThemeResource ScheduleItemContainerStyle}"/>
  </Style>

  <Style x:Key="ExtScheduleListViewStyle" BasedOn="{ThemeResource TVListViewStyle}">
    <Setter Property="ItemTemplate" Value="{ThemeResource ExtScheduleItemDataTemplate}"/>
    <Setter Property="ItemContainerStyle" Value="{ThemeResource ExtScheduleItemContainerStyle}"/>
  </Style>

</ResourceDictionary>
