<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:bpa="clr-namespace:BPA.UIControl">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/Resources/Default.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="RubyerPageBarItem" TargetType="{x:Type bpa:PageBarItem}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Foreground" Value="{DynamicResource WhiteForeground}" />
        <Setter Property="MinWidth" Value="30" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Padding" Value="{Binding ItemsPadding, RelativeSource={RelativeSource AncestorType=bpa:PageBar}}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type bpa:PageBarItem}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Button x:Name="pageButton"
                                MinWidth="{TemplateBinding MinWidth}"
                                Margin="{TemplateBinding Padding}"
                                Background="{Binding UnselectedBrush, RelativeSource={RelativeSource AncestorType=bpa:PageBar}}"
                                Command="{Binding Command}"
                                CommandParameter="{Binding Value}"
                                Content="{Binding Content}"
                                Foreground="{TemplateBinding Foreground}"
                                IsEnabled="{Binding IsEnabled}"
                                ToolTip="{Binding ToolTip}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <DataTrigger Value="True">
                            <DataTrigger.Binding>
                                <MultiBinding Converter="{StaticResource IsEqualConverter}">
                                    <Binding Path="Value" />
                                    <Binding Path="PageIndex" RelativeSource="{RelativeSource AncestorType=bpa:PageBar}" />
                                </MultiBinding>
                            </DataTrigger.Binding>
                            <Setter TargetName="pageButton" Property="Background" Value="{Binding SelectedBrush, RelativeSource={RelativeSource AncestorType=bpa:PageBar}}" />
                            <Setter TargetName="pageButton" Property="Foreground" Value="{Binding SelectedForeground, RelativeSource={RelativeSource AncestorType=bpa:PageBar}}" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding IsRound, RelativeSource={RelativeSource AncestorType=bpa:PageBar}}" Value="True">
                            <Setter TargetName="pageButton" Property="bpa:ButtonHelper.Shape" Value="Round" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="TextPageBarItem" TargetType="{x:Type bpa:PageBarItem}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Foreground" Value="{DynamicResource DefaultForeground}" />
        <Setter Property="MinWidth" Value="30" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Padding" Value="{Binding ItemsPadding, RelativeSource={RelativeSource AncestorType=bpa:PageBar}}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type bpa:PageBarItem}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Button x:Name="pageButton"
                                MinWidth="{TemplateBinding MinWidth}"
                                Margin="{TemplateBinding Padding}"
                                Background="Transparent"
                                Command="{Binding Command}"
                                CommandParameter="{Binding Value}"
                                Content="{Binding Content}"
                                FontSize="{TemplateBinding FontSize}"
                                Foreground="{TemplateBinding Foreground}"
                                IsEnabled="{Binding IsEnabled}"
                                ToolTip="{Binding ToolTip}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <DataTrigger Value="True">
                            <DataTrigger.Binding>
                                <MultiBinding Converter="{StaticResource IsEqualConverter}">
                                    <Binding Path="Value" />
                                    <Binding Path="PageIndex" RelativeSource="{RelativeSource AncestorType=bpa:PageBar}" />
                                </MultiBinding>
                            </DataTrigger.Binding>
                            <Setter Property="Foreground" Value="{Binding SelectedBrush, RelativeSource={RelativeSource AncestorType=bpa:PageBar}}" />
                            <Setter Property="FontWeight" Value="Bold" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding IsRound, RelativeSource={RelativeSource AncestorType=bpa:PageBar}}" Value="True">
                            <Setter TargetName="pageButton" Property="bpa:ButtonHelper.Shape" Value="Round" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="RubyerPageBar" TargetType="{x:Type bpa:PageBar}">
        <Setter Property="Foreground" Value="{DynamicResource DefaultForeground}" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="UnselectedBrush" Value="{DynamicResource Primary}" />
        <Setter Property="SelectedBrush" Value="{DynamicResource Dark}" />
        <Setter Property="SelectedForeground" Value="{DynamicResource WhiteForeground}" />
        <Setter Property="Foreground" Value="{DynamicResource DefaultForeground}" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="ItemContainerStyle" Value="{StaticResource RubyerPageBarItem}" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="IsShowPageSize" Value="True" />
        <Setter Property="IsShowTotal" Value="True" />
        <Setter Property="ItemsDock" Value="Right" />
        <Setter Property="ItemsPadding" Value="3 0" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <WrapPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type bpa:PageBar}">
                    <DockPanel Margin="{TemplateBinding Padding}" Background="{TemplateBinding Background}">
                        <ItemsPresenter x:Name="items"
                                        Margin="5 0"
                                        DockPanel.Dock="{TemplateBinding ItemsDock}"
                                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />

                        <StackPanel x:Name="pageInfo"
                                    VerticalAlignment="Center"
                                    Orientation="Horizontal">
                            <TextBlock VerticalAlignment="Center"
                                       Foreground="{TemplateBinding Foreground}"
                                       Text="{DynamicResource I18N_PageBar_Total}"
                                       Visibility="{TemplateBinding IsShowTotal, Converter={StaticResource BooleanToVisibleConverter}}" />
                            <TextBlock Margin="5 0 0 0"
                                       VerticalAlignment="Center"
                                       FontWeight="Bold"
                                       Foreground="{TemplateBinding Foreground}"
                                       Text="{Binding Total, RelativeSource={RelativeSource AncestorType=bpa:PageBar}}"
                                       Visibility="{TemplateBinding IsShowTotal, Converter={StaticResource BooleanToVisibleConverter}}" />
                            <TextBlock Margin="5 0 10 0"
                                       VerticalAlignment="Center"
                                       Foreground="{TemplateBinding Foreground}"
                                       Text="{DynamicResource I18N_PageBar_Piece}"
                                       Visibility="{TemplateBinding IsShowTotal, Converter={StaticResource BooleanToVisibleConverter}}" />

                            <ComboBox MinWidth="90"
                                      VerticalAlignment="Center"
                                      bpa:ControlHelper.FocusBorderBrush="{TemplateBinding SelectedBrush}"
                                      bpa:ControlHelper.MouseOverBrush="{TemplateBinding SelectedBrush}"
                                      bpa:InputBoxHelper.IsRound="{TemplateBinding IsRound}"
                                      bpa:InputBoxHelper.PostContent="{DynamicResource I18N_PageBar_PageSize}"
                                      ItemsSource="{TemplateBinding PageSizeCollection}"
                                      SelectedItem="{Binding PageSize, RelativeSource={RelativeSource AncestorType=bpa:PageBar}}"
                                      Visibility="{TemplateBinding IsShowPageSize, Converter={StaticResource BooleanToVisibleConverter}}" />
                        </StackPanel>
                    </DockPanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="ItemsDock" Value="Left">
                            <Setter TargetName="pageInfo" Property="HorizontalAlignment" Value="Right" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="TextPageBar" TargetType="{x:Type bpa:PageBar}">
        <Setter Property="ItemContainerStyle" Value="{StaticResource TextPageBarItem}" />
    </Style>

</ResourceDictionary>