<Application
    x:Class="BPA.SingleDevice.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/Resources/I18N/zh-CN.xaml" />
                <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/Generic.xaml" />
                <!--<ResourceDictionary Source="pack://application:,,,/Rubyer;component/Themes/Generic.xaml" />-->
                <ResourceDictionary Source="/BPA.SingleDevice;component/Themes/ThemesColor.xaml" />
                <!--<ResourceDictionary Source="/BPA.SingleDevice;component/Themes/Generic.xaml" />-->
            </ResourceDictionary.MergedDictionaries>
            <Style
                x:Key="DataGridLargeScrollStyle"
                BasedOn="{StaticResource RubyerDataGrid}"
                TargetType="{x:Type DataGrid}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type DataGrid}">
                            <Border
                                x:Name="border"
                                Padding="{TemplateBinding Padding}"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                SnapsToDevicePixels="True">
                                <ScrollViewer
                                    x:Name="DG_ScrollViewer"
                                    bpa:ScrollViewerHelper.ScrollBarSize="40"
                                    Background="Transparent"
                                    Focusable="False"
                                    Style="{StaticResource RubyerScrollViewer}">
                                    <ScrollViewer.Template>
                                        <ControlTemplate TargetType="{x:Type ScrollViewer}">
                                            <Grid x:Name="root">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="Auto" />
                                                    <ColumnDefinition Width="*" />
                                                    <ColumnDefinition Width="Auto" />
                                                </Grid.ColumnDefinitions>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="*" />
                                                    <RowDefinition Height="Auto" />
                                                </Grid.RowDefinitions>


                                                <DataGridColumnHeader
                                                    Width="{Binding RowHeaderActualWidth, RelativeSource={RelativeSource AncestorType=DataGrid}}"
                                                    Command="DataGrid.SelectAllCommand"
                                                    Style="{StaticResource FirstDataGridColumnHeader}"
                                                    Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}">
                                                    <ContentControl Content="{Binding Path=(bpa:DataGridHelper.RowHeaderTitle), RelativeSource={RelativeSource AncestorType=DataGrid}}" />
                                                </DataGridColumnHeader>

                                                <DataGridColumnHeadersPresenter
                                                    x:Name="PART_ColumnHeadersPresenter"
                                                    Grid.Column="1"
                                                    Grid.ColumnSpan="2"
                                                    Style="{StaticResource RubyerDataGridColumnHeadersPresenter}"
                                                    Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
                                                <ScrollContentPresenter
                                                    x:Name="PART_ScrollContentPresenter"
                                                    Grid.Row="1"
                                                    Grid.RowSpan="2"
                                                    Grid.ColumnSpan="3"
                                                    CanContentScroll="{TemplateBinding CanContentScroll}" />

                                                <ScrollBar
                                                    x:Name="PART_VerticalScrollBar"
                                                    Grid.Row="1"
                                                    Grid.Column="2"
                                                    Maximum="{TemplateBinding ScrollableHeight}"
                                                    Orientation="Vertical"
                                                    Style="{StaticResource RubyerScrollBar}"
                                                    ViewportSize="{TemplateBinding ViewportHeight}"
                                                    Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                                                    Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />

                                                <ScrollBar
                                                    x:Name="PART_HorizontalScrollBar"
                                                    Grid.Row="2"
                                                    Grid.ColumnSpan="2"
                                                    Maximum="{TemplateBinding ScrollableWidth}"
                                                    Orientation="Horizontal"
                                                    Style="{StaticResource RubyerScrollBar}"
                                                    ViewportSize="{TemplateBinding ViewportWidth}"
                                                    Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                                                    Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />

                                                <Border
                                                    x:Name="emptyBorder"
                                                    Grid.Row="1"
                                                    Grid.ColumnSpan="3"
                                                    Visibility="Collapsed">
                                                    <ContentControl x:Name="emptyView" Content="{Binding Path=(bpa:DataGridHelper.EmptyView), RelativeSource={RelativeSource AncestorType=DataGrid}}" />
                                                </Border>

                                                <Border
                                                    x:Name="loadingBorder"
                                                    Grid.Row="1"
                                                    Grid.ColumnSpan="3"
                                                    Background="{DynamicResource DialogBackground}"
                                                    Visibility="Collapsed">
                                                    <bpa:Card
                                                        Padding="10"
                                                        HorizontalAlignment="Center"
                                                        VerticalAlignment="Center">
                                                        <bpa:Loading
                                                            x:Name="loading"
                                                            Background="Transparent"
                                                            Content="{Binding Path=(bpa:DataGridHelper.LoadingContent), RelativeSource={RelativeSource AncestorType=DataGrid}}" />
                                                    </bpa:Card>
                                                </Border>
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <DataTrigger Binding="{Binding Items.Count, RelativeSource={RelativeSource Mode=TemplatedParent}}" Value="0">
                                                    <Setter TargetName="emptyBorder" Property="Visibility" Value="Visible" />
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Path=(bpa:DataGridHelper.Loading), RelativeSource={RelativeSource AncestorType=DataGrid}}" Value="True">
                                                    <Setter TargetName="loadingBorder" Property="Visibility" Value="Visible" />
                                                </DataTrigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </ScrollViewer.Template>

                                    <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                </ScrollViewer>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <Trigger Property="IsGrouping" Value="True">
                        <Setter Property="ScrollViewer.CanContentScroll" Value="False" />
                    </Trigger>
                    <Trigger Property="IsEnabled" Value="False">
                        <Setter Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
                    </Trigger>
                </Style.Triggers>
            </Style>

            <Style
                x:Key="LargeScrollListView"
                BasedOn="{StaticResource RubyerListView}"
                TargetType="{x:Type ListView}">
                <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ListView">
                            <Border
                                Name="Border"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                                <ScrollViewer bpa:ScrollViewerHelper.ScrollBarSize="60" Style="{DynamicResource {x:Static GridView.GridViewScrollViewerStyleKey}}">
                                    <ItemsPresenter />
                                </ScrollViewer>
                            </Border>
                            <ControlTemplate.Triggers>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsGrouping" Value="True" />
                                        <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="False" />
                                    </MultiTrigger.Conditions>
                                    <Setter Property="ScrollViewer.CanContentScroll" Value="False" />
                                </MultiTrigger>
                                <Trigger Property="IsEnabled" Value="False">
                                    <Setter Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style
                x:Key="LargeScrollComboBoxStyle"
                BasedOn="{StaticResource RubyerComboBox}"
                TargetType="{x:Type ComboBox}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ComboBox}">
                            <Grid
                                x:Name="templateRoot"
                                Background="Transparent"
                                SnapsToDevicePixels="True">

                                <Popup
                                    x:Name="PART_Popup"
                                    Grid.ColumnSpan="2"
                                    MaxHeight="{TemplateBinding MaxDropDownHeight}"
                                    AllowsTransparency="True"
                                    HorizontalOffset="-5"
                                    IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                    Placement="Bottom"
                                    PopupAnimation="Fade">
                                    <Popup.MinWidth>
                                        <MultiBinding Converter="{StaticResource ComboBoxPopupWidth}">
                                            <Binding ElementName="templateRoot" Path="ActualWidth" />
                                            <Binding ElementName="dropDownBorder" Path="Margin.Left" />
                                        </MultiBinding>
                                    </Popup.MinWidth>
                                    <Grid>
                                        <Border
                                            x:Name="dropDownBorder"
                                            Margin="5"
                                            Background="{DynamicResource FloatBackground}"
                                            CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                            Effect="{DynamicResource AllDirectionEffect}" />
                                        <ScrollViewer
                                            x:Name="DropDownScrollViewer"
                                            Margin="5,10"
                                            bpa:ScrollViewerHelper.ScrollBarSize="100"
                                            Style="{StaticResource SmallScrollViewer}">
                                            <Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
                                                <ItemsPresenter
                                                    x:Name="ItemsPresenter"
                                                    KeyboardNavigation.DirectionalNavigation="Contained"
                                                    OverridesDefaultStyle="True"
                                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                            </Grid>
                                        </ScrollViewer>
                                    </Grid>
                                </Popup>

                                <ToggleButton
                                    x:Name="toggleButton"
                                    Grid.ColumnSpan="2"
                                    Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                    Style="{StaticResource RubyerComboBoxToggleButton}">
                                    <Grid
                                        Margin="{Binding Path=(bpa:InputBoxHelper.InternalSpacing), Converter={StaticResource DoubleToLeftAndRightThicknessConverter}, RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                        bpa:GridHelper.ColumnDefinitions="Auto,*,Auto,Auto"
                                        bpa:PanelHelper.Spacing="{Binding Path=(bpa:InputBoxHelper.InternalSpacing), RelativeSource={RelativeSource Mode=TemplatedParent}}">

                                        <ContentControl
                                            x:Name="preContent"
                                            Grid.Column="0"
                                            VerticalAlignment="Center"
                                            Content="{Binding Path=(bpa:InputBoxHelper.PreContent), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                            Foreground="{DynamicResource SeconarydText}"
                                            IsHitTestVisible="False"
                                            IsTabStop="False" />

                                        <Grid Grid.Column="1" VerticalAlignment="Center">
                                            <ContentPresenter
                                                x:Name="contentPresenter"
                                                Margin="{TemplateBinding Padding}"
                                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                Content="{TemplateBinding SelectionBoxItem}"
                                                ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
                                                ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                                ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                                IsHitTestVisible="False"
                                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />

                                            <TextBlock
                                                x:Name="multiSelectText"
                                                Margin="{TemplateBinding Padding}"
                                                VerticalAlignment="Center"
                                                IsHitTestVisible="False"
                                                Text="{Binding Path=(bpa:ComboBoxHelper.MultiSelectText), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                                Visibility="Collapsed" />

                                            <TextBlock
                                                x:Name="watermark"
                                                VerticalAlignment="Center"
                                                Foreground="{DynamicResource WatermarkText}"
                                                IsHitTestVisible="False"
                                                Text="{Binding Path=(bpa:InputBoxHelper.Watermark), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
                                        </Grid>

                                        <Button
                                            x:Name="clearButton"
                                            Grid.Column="2"
                                            Padding="2"
                                            bpa:ButtonHelper.Shape="Circle"
                                            Focusable="False"
                                            Foreground="{DynamicResource SeconarydText}"
                                            Style="{StaticResource TextButton}"
                                            Visibility="Collapsed">
                                            <bpa:Icon Type="CloseLine" />
                                        </Button>

                                        <ContentControl
                                            x:Name="postContent"
                                            Grid.Column="3"
                                            VerticalAlignment="Center"
                                            Content="{Binding Path=(bpa:InputBoxHelper.PostContent), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                            Foreground="{DynamicResource SeconarydText}"
                                            IsHitTestVisible="False"
                                            IsTabStop="False" />
                                    </Grid>
                                </ToggleButton>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsEnabled" Value="False">
                                    <Setter TargetName="templateRoot" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
                                </Trigger>
                                <Trigger Property="HasItems" Value="False">
                                    <Setter TargetName="dropDownBorder" Property="Height" Value="100" />
                                </Trigger>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsGrouping" Value="True" />
                                        <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="False" />
                                    </MultiTrigger.Conditions>
                                    <Setter Property="ScrollViewer.CanContentScroll" Value="False" />
                                </MultiTrigger>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="bpa:ControlHelper.IsKeyBoardFocused" Value="True" />
                                        <Condition Property="bpa:InputBoxHelper.IsClearable" Value="True" />
                                    </MultiTrigger.Conditions>
                                    <!--<Setter TargetName="clearButton" Property="Visibility" Value="Visible" />-->
                                </MultiTrigger>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsMouseOver" Value="True" />
                                        <Condition Property="bpa:InputBoxHelper.IsClearable" Value="True" />
                                    </MultiTrigger.Conditions>
                                    <Setter TargetName="clearButton" Property="Visibility" Value="Visible" />
                                </MultiTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding Path=(bpa:ComboBoxHelper.IsMultiSelect), RelativeSource={RelativeSource Self}}" Value="False" />
                                        <Condition Binding="{Binding Path=Content, ElementName=contentPresenter, Converter={StaticResource IsNullOrEmptyConverter}}" Value="False" />
                                    </MultiDataTrigger.Conditions>
                                    <Setter TargetName="watermark" Property="Visibility" Value="Hidden" />
                                </MultiDataTrigger>
                                <Trigger Property="bpa:InputBoxHelper.IsRound" Value="True">
                                    <Setter Property="bpa:ControlHelper.CornerRadius" Value="{Binding ActualHeight, RelativeSource={RelativeSource Self}, Converter={StaticResource HalfOfDoubleConverter}}" />
                                </Trigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding Path=(bpa:ComboBoxHelper.IsMultiSelect), RelativeSource={RelativeSource Self}}" Value="True" />
                                        <Condition Binding="{Binding Path=Text, ElementName=multiSelectText, Converter={StaticResource IsNullOrEmptyConverter}}" Value="False" />
                                    </MultiDataTrigger.Conditions>
                                    <Setter TargetName="watermark" Property="Visibility" Value="Hidden" />
                                </MultiDataTrigger>
                                <DataTrigger Binding="{Binding Path=(bpa:ComboBoxHelper.IsMultiSelect), RelativeSource={RelativeSource Self}}" Value="True">
                                    <Setter TargetName="contentPresenter" Property="Visibility" Value="Collapsed" />
                                    <Setter TargetName="multiSelectText" Property="Visibility" Value="Visible" />
                                </DataTrigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>
    </Application.Resources>
</Application>