<UserControl x:Class="Valg.EVA.Skanning.Verify.Startup.VerifyBallotPaper.RenumberStrikeout.RenumberStrikeoutPageControl"
             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:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:verify="clr-namespace:Valg.EVA.Skanning.Verify.Startup.VerifyBallotPaper"
             xmlns:renumberStrikeout="clr-namespace:Valg.EVA.Skanning.Verify.Startup.VerifyBallotPaper.RenumberStrikeout"
             xmlns:candidate="clr-namespace:Valg.EVA.Skanning.Verify.Startup.VerifyBallotPaper.Candidate"
             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 renumberStrikeout:RenumberStrikeoutPageViewModel}">
    <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}" />
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0" Text="{Binding VerifyLanguageString.RenumberColumnText, FallbackValue='Nr'}" Style="{StaticResource TextBlockLarge}" Margin="7,5,0,5"></TextBlock>
            <TextBlock HorizontalAlignment="Right" Grid.Column="1" Text="{Binding VerifyLanguageString.StrikeoutColumnText, FallbackValue='Stryk'}" Style="{StaticResource TextBlockLarge}" Margin="0,5,7,5"></TextBlock>
        </Grid>
        <ItemsControl HorizontalAlignment="Stretch" VerticalAlignment="Center" BorderThickness="0" ItemsSource="{Binding RenumberStrikeoutsForPage}" IsTabStop="False" AlternationCount="2" 
                      verify:ActiveMainControlManager.IsMainControl="True" 
                      KeyboardNavigation.DirectionalNavigation="Cycle">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Border x:Name="DataTemplateBorder">
                        <StackPanel>
                            <ToggleButton 
                                Tag="FocusElement" 
                                IsChecked="{Binding IsContextMenuOpen}"
                                Style="{StaticResource ToggleButtonWithPopupRenumberStrikeout}" 
                                userInterfaceElements:FocusExtension.IsFocused="{Binding IsActionButtonFocused}"
                                HorizontalAlignment="Stretch"/>
                            <renumberStrikeout:FocusedRenumberStrikeoutPopup
                                        AllowsTransparency="True" 
                                        IsOpen="{Binding IsContextMenuOpen}" 
                                        StaysOpen="False" 
                                        PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                        Tag="Candidate"
                                        HorizontalOffset="105">
                                <Border Style="{StaticResource PopupBorder}">
                                    <ItemsControl ItemsSource="{Binding VerifyCommand}" Style="{StaticResource VerifyItemsStyle}" IsTabStop="False">
                                        <ItemsControl.Resources>
                                            <DataTemplate DataType="{x:Type renumberStrikeout:RenumberStrikeoutContextMenuViewModel}">
                                                <StackPanel>
                                                    <ToggleButton 
                                                        Content="{Binding DisplayName}"
                                                        Style="{StaticResource ToggleButtonContextMenu}"
                                                        Visibility="{Binding ShowRenumberOption, Converter={StaticResource BooleanToVisibilityConverter}}"
                                                        IsChecked="{Binding IsRenumberValuesOpen}"/>
                                                    <renumberStrikeout:FocusedRenumberValuesPopup
                                                        AllowsTransparency="True" 
                                                        IsOpen="{Binding IsRenumberValuesOpen}" 
                                                        StaysOpen="False" 
                                                        PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                                        PopupAnimation="Fade"
                                                        HorizontalOffset="0">
                                                        <Border Style="{StaticResource RenumberValuesPopupBorder}">
                                                            <ScrollViewer VerticalScrollBarVisibility="Auto" CanContentScroll="True">
                                                                <renumberStrikeout:RenumberListBox x:Name="RenumberValuesListBox" TextSearch.TextPath="Value" IsTextSearchEnabled="True"
                                                                ItemsSource="{Binding PossibleRenumberValues}"
                                                                ItemContainerStyle="{StaticResource RenumberValues}"
                                                                IsTabStop="False"
                                                                KeyboardNavigation.DirectionalNavigation="Cycle"
                                                                BorderThickness="0"
                                                                Margin="1">
                                                                </renumberStrikeout:RenumberListBox>
                                                            </ScrollViewer>
                                                        </Border>
                                                    </renumberStrikeout:FocusedRenumberValuesPopup>
                                                </StackPanel>
                                            </DataTemplate>
                                            <DataTemplate DataType="{x:Type candidate:ContextMenuViewModel}">
                                                <Button Content="{Binding DisplayName}" Command="{Binding Command}" Style="{StaticResource RenumberButtonContextMenu}"/>
                                            </DataTemplate>
                                        </ItemsControl.Resources>
                                    </ItemsControl>
                                </Border>
                            </renumberStrikeout:FocusedRenumberStrikeoutPopup>
                        </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>








