<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"                    
                    xmlns:cvt="clr-namespace:MWS.Domain.Common.Converts"
                    xmlns:cvt2="clr-namespace:MWS.Library.Enums;assembly=MWS.Library"
                    xmlns:local="clr-namespace:MWS.Domain.Common.ControlHelper">

    <cvt:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
    <cvt2:EnumConverter x:Key="EnumsConverter"/>
    <Style x:Key="ListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
        <Setter Property="Background" Value="{Binding PageSelectorBackground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:Pagination}}"/>
        <Setter Property="Foreground" Value="#FFFFFF"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border x:Name="Bd" Height="auto" Margin="5,0,0,0" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0" Background="{TemplateBinding Background}"  SnapsToDevicePixels="true">
                        <ContentPresenter HorizontalAlignment="Stretch" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Bd"
                                    Property="BorderBrush"
                                    Value="Transparent" />
                            <Setter TargetName="Bd"
                                    Property="Background"
                                    Value="#2DA6EC" />
                        </Trigger>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter Property="Background"
                                    TargetName="Bd"
                                    Value="{Binding SelectedPageBackground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:Pagination}}"/>
                            <!--<Setter Property="Foreground" Value="#FFFFFF"/>-->
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:Pagination}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:Pagination}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>

                            <StackPanel Orientation="Horizontal" Height="Auto" Grid.Column="0" VerticalAlignment="Center">
                                <!--每页数据量选择-->
                                <ComboBox x:Name="PART_ComboBox"    Style="{StaticResource DefaultComboBoxStyle}"
                                          Visibility="{TemplateBinding IsShowPageDataCountSelector,Converter={StaticResource BoolToVisibilityConverter}}"                                     
                                          Width="70" Height="51"  Margin="0,0,10,0"  Padding="15,12"
                                          SelectedIndex="0" BorderBrush="Transparent" BorderThickness="0"
                                          ItemsSource="{TemplateBinding PageDataCountCollection}">
                                </ComboBox>

                                <Button x:Name="PART_ButtonFirstPage"
                                        Content="首页"
                                        MinWidth="60"
                                        BorderThickness="0" Margin="10,0"
                                        FontSize="20" Padding="15,12"
                                        Style="{StaticResource PaginationButtonStyle}"/>

                                <Button x:Name="PART_ButtonPrePage"
                                        Content="上一页"
                                        MinWidth="90"
                                        FontSize="20" Padding="15,12"
                                        Margin="10,0,5,0"
                                        Style="{StaticResource PaginationButtonStyle}"
                                        BorderThickness="0"/>

                                <ListBox x:Name="PART_ListBoxPages"
                                         HorizontalAlignment="Left" 
                                         ItemContainerStyle="{StaticResource ListBoxItemStyle}"
                                         ItemsSource="{TemplateBinding ShowingPageNumberCollection}"
                                         SelectedIndex="0" 
                                         Background="Transparent"
                                         BorderThickness="0"
                                         ScrollViewer.VerticalScrollBarVisibility="Hidden">
                                    <ListBox.ItemTemplate>
                                        <DataTemplate>
                                            <Grid>
                                                <Label Content="{Binding}" 
                                                       Width="46" Height="46" 
                                                       HorizontalAlignment="Center"
                                                       VerticalAlignment="Center" 
                                                       FontSize="20" 
                                                       Foreground="#4D4E4F"
                                                       BorderThickness="0"
                                                       Cursor="Hand"
                                                       HorizontalContentAlignment="Center"
                                                       VerticalContentAlignment="Center"/>
                                            </Grid>
                                        </DataTemplate>
                                    </ListBox.ItemTemplate>
                                    <ListBox.ItemsPanel>
                                        <ItemsPanelTemplate>
                                            <VirtualizingStackPanel Orientation="Horizontal"
                                                                    IsItemsHost="True" />
                                        </ItemsPanelTemplate>
                                    </ListBox.ItemsPanel>
                                </ListBox>

                                <Button x:Name="PART_ButtonNextPage"
                                        Content="下一页"
                                        MinWidth="90"
                                        FontSize="20" Padding="15,12"
                                        Margin="10,0,0,0"
                                        Style="{StaticResource PaginationButtonStyle}"
                                        BorderThickness="0"/>

                                <Button x:Name="PART_ButtonLastPage"
                                        Content="尾页"
                                        MinWidth="55" Padding="15,12"
                                        FontSize="20"
                                        Margin="10,0,0,0"
                                        BorderThickness="0"
                                        Style="{StaticResource PaginationButtonStyle}"/>
                            </StackPanel>

                            <StackPanel x:Name="PART_PageInfo" Grid.Column="1" 
                                        Orientation="Horizontal" 
                                        VerticalAlignment="Center"
                                        Margin="50,0,0,0"
                                        Visibility="{TemplateBinding IsShowPageInfo,Converter={StaticResource BoolToVisibilityConverter}}">
                                <TextBlock Foreground="#AAAAAA" FontSize="20">
                                    <TextBlock.Text>
                                        <MultiBinding StringFormat="{}{0}-{1}条，共{2}页，共{3}条记录">
                                            <Binding Path="ShowingPageDataStartNumber" RelativeSource="{RelativeSource TemplatedParent}"/>
                                            <Binding Path="ShowingPageDataEndNumber" RelativeSource="{RelativeSource TemplatedParent }"/>
                                            <Binding Path="TotalPageCount" RelativeSource="{RelativeSource TemplatedParent}"/>
                                            <Binding Path="TotalDataCount" RelativeSource="{RelativeSource TemplatedParent}"/>
                                        </MultiBinding>
                                    </TextBlock.Text>
                                </TextBlock>
                            </StackPanel>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>