<UserControl x:Class="Valg.EVA.Skanning.Verify.Startup.VerifyBallotPaper.Candidate.CandidatePageControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:candidate="clr-namespace:Valg.EVA.Skanning.Verify.Startup.VerifyBallotPaper.Candidate"
             xmlns:verify="clr-namespace:Valg.EVA.Skanning.Verify.Startup.VerifyBallotPaper"
             xmlns:userInterfaceElements="clr-namespace:Valg.EVA.Skanning.UserInterfaceElements;assembly=Valg.EVA.Skanning.UserInterfaceElements"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance candidate:CandidatePageViewModel}">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Valg.EVA.Skanning.Assets;component/ResourceDictionaries/ResourceLibrary.xaml"/>
            </ResourceDictionary.MergedDictionaries>            
        </ResourceDictionary>
    </UserControl.Resources>
    <StackPanel>
        <TextBlock Text="{Binding ElectionListDisplayName}" Style="{StaticResource TextBlockBlackWhiteHeader}" />
        <ItemsControl HorizontalAlignment="Stretch" VerticalAlignment="Center" BorderThickness="0" ItemsSource="{Binding CandidatesForPage}" IsTabStop="False" AlternationCount="2" 
                      verify:ActiveMainControlManager.IsMainControl="True" >
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Border x:Name="DataTemplateBorder">
                        <StackPanel>
                            <ToggleButton Tag="FocusElement" IsChecked="{Binding IsContextMenuOpen}" 
                                                              Style="{StaticResource ToggleButtonWithPopupCandidate}" 
                                                              userInterfaceElements:FocusExtension.IsFocused="{Binding IsActionButtonFocused}"
                                                              HorizontalAlignment="Stretch"/>
                            <userInterfaceElements:FocusedPopup
                                                    AllowsTransparency="True" 
                                        IsOpen="{Binding IsContextMenuOpen}" 
                                        StaysOpen="False" 
                                        PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                        Tag="Candidate"
                                        HorizontalOffset="100">
                                <Border Style="{StaticResource PopupBorder}">
                                    <ItemsControl ItemsSource="{Binding VerifyCommand}" Style="{StaticResource VerifyItemsStyle}" IsTabStop="False">
                                        <ItemsControl.ItemTemplate>
                                            <DataTemplate>
                                                <Button Content="{Binding DisplayName}" Command="{Binding Command}" Style="{StaticResource ButtonContextMenu}"/>
                                            </DataTemplate>
                                        </ItemsControl.ItemTemplate>
                                    </ItemsControl>
                                </Border>
                            </userInterfaceElements:FocusedPopup>
                        </StackPanel>
                    </Border>
                    <DataTemplate.Triggers>
                        <Trigger Property="ItemsControl.AlternationIndex" Value="0">
                            <Setter Property="Background" Value="#E4E4E4" TargetName="DataTemplateBorder"></Setter>
                        </Trigger>
                        <Trigger Property="ItemsControl.AlternationIndex" Value="1">
                            <Setter Property="Background" Value="White" TargetName="DataTemplateBorder"></Setter>
                        </Trigger>
                    </DataTemplate.Triggers>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </StackPanel>
</UserControl>


