<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:local="clr-namespace:CustomTheme"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
  
    xmlns:grid="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"
        xmlns:controls="clr-namespace:Telerik.Windows.Controls"
	
	xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     >
    
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Resources.xaml"/>
        <ResourceDictionary Source="GridViewScrollViewer_x.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    
    <local:MyCustomTheme x:Key="Theme" />
    
    <!-- Style for TextBox -->
    <Style x:Key="TextBoxStyle" TargetType="TextBox">
        <Setter Property="Foreground" Value="{StaticResource TextBoxForeground}"/>
        <Setter Property="Background" Value="{StaticResource TextBoxBackground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource TextBoxBorderBrush}"/>
        <Setter Property="BorderThickness" Value="1,1,1,1"/>
        <Setter Property="Padding" Value="1"/>

        <Setter Property="AllowDrop" Value="True"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TextBox">

                    <Border x:Name="TextBoxBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
                        <ScrollViewer x:Name="PART_ContentHost" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter TargetName="TextBoxBorder" Property="BorderBrush" Value="{StaticResource TextBoxBackground_Over}" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="TextBoxBorder" Property="BorderBrush" Value="{StaticResource TextBoxBackground_Pressed}" />
                        </Trigger>
                    </ControlTemplate.Triggers>


                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!--  style for CheckBox -->

    <Style TargetType="CheckBox" x:Key="CheckBoxItem">
        <Setter Property="Background" Value="{StaticResource CheckBoxBackground}"/>
        <Setter Property="Foreground" Value="{StaticResource CheckBoxForeground}"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Top"/>
        <Setter Property="Padding" Value="4,1,0,0"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="{StaticResource CheckBoxBorderBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="CheckBox">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="16"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <Grid HorizontalAlignment="Left" VerticalAlignment="Center">
                            <Rectangle x:Name="Background" Width="14" Height="14" RadiusX="0" RadiusY="0" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}" Fill="{StaticResource CheckBoxBackgroundFill}" Margin="1"/>
                            <Rectangle x:Name="BackgroundOverlay" Fill="{StaticResource CheckBoxBackgroundOverlayFill}" Opacity="0" Width="14" Height="14" RadiusX="0" RadiusY="0" StrokeThickness="1" Margin="1" Stroke="{StaticResource CheckBoxBackgroundOverlayStroke}"/>
                            <Rectangle x:Name="BackgroundPressed" Fill="{StaticResource CheckBoxBackgroundPressedFill}" Opacity="0" Width="14" Height="14" RadiusX="0" RadiusY="0" StrokeThickness="1" Margin="1" Stroke="{StaticResource CheckBoxBackgroundPressedStroke}"/>
                            <Rectangle x:Name="BoxMiddleBackground" Width="10" Height="10" RadiusX="0" RadiusY="0" Fill="{TemplateBinding Background}" Stroke="#00000000" StrokeThickness="1"/>
                            <Rectangle x:Name="BoxMiddle" Width="10" Height="10" RadiusX="0" RadiusY="0" StrokeThickness="1"  Stroke="{StaticResource CheckBoxMiddleStroke}" Fill="{StaticResource CheckBoxMiddleFill}"/>

                            <Rectangle x:Name="BoxMiddleLine" Width="10" Height="10" RadiusX="0" RadiusY="0" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" Opacity=".2"/>

                            <Path x:Name="CheckIcon" Margin="0,1,0,1.5" Stretch="Fill" Opacity="0" Width="9" Height="8" Stroke="{StaticResource CheckBoxCheckIconStroke}" StrokeThickness="2" Data="M32.192282,77.371554 L34.688632,80.304322 38.863374,72.720928"/>
                            <Rectangle x:Name="IndeterminateIcon" Height="2" Fill="{StaticResource CheckBoxCheckIndeterminateIconFill}" Opacity="0" Width="6"/>
                            <Rectangle x:Name="DisabledVisualElement" RadiusX="0" RadiusY="0" Width="14" Height="14" Opacity="0" Fill="{StaticResource CheckBoxDisabledVisualElementFill}"/>
                            <Rectangle x:Name="ContentFocusVisualElement" RadiusX="0" RadiusY="0" Stroke="{StaticResource CheckBoxContentFocusVisualElementStroke}" StrokeThickness="0" Opacity="0" IsHitTestVisible="false" Width="16" Height="16" />
                        </Grid>
                        <ContentPresenter
								Grid.Column="1"
								x:Name="contentPresenter"
								Content="{TemplateBinding Content}"
								ContentTemplate="{TemplateBinding ContentTemplate}"
								HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
								VerticalAlignment="Center"
								Margin="{TemplateBinding Padding}"/>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Stroke" TargetName="BoxMiddle" Value="{StaticResource DistinctFilterCheckboxMouseOverStroke}" />
                            <Setter Property="Fill" TargetName="BoxMiddle" Value="{StaticResource DistinctFilterCheckboxMouseOverFill}" />
                        </Trigger>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter Property="Opacity" TargetName="CheckIcon" Value="1" />
                        </Trigger>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter Property="Opacity" TargetName="ContentFocusVisualElement" Value="1" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" TargetName="DisabledVisualElement" Value="0.55" />
                            <Setter Property="Opacity" TargetName="contentPresenter" Value="0.55" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Stroke" TargetName="BoxMiddle" Value="{StaticResource DistinctFilterCheckboxPressedStroke}" />
                            <Setter Property="Fill" TargetName="BoxMiddle" Value="{StaticResource DistinctFilterCheckboxPressedFill}" />
                        </Trigger>
                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>



    <!-- ScrollViewer -->

    <SolidColorBrush x:Key="ListBorder" Color="#828790"/>
    <ControlTemplate x:Key="ScrollViewerControlTemplate" TargetType="{x:Type ScrollViewer}">
        <Grid x:Name="Grid" Background="{TemplateBinding Background}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Rectangle x:Name="Corner" Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Grid.Column="1" Grid.Row="1"/>
            <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" Margin="{TemplateBinding Padding}" Grid.Column="0" Grid.Row="0" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False"/>
            <ScrollBar x:Name="PART_VerticalScrollBar" Cursor="Arrow" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Grid.Column="1" Grid.Row="0" AutomationProperties.AutomationId="VerticalScrollBar" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Value="{Binding Path=VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}" Style="{StaticResource VerticalScrollBarStyle}"/>
            <ScrollBar x:Name="PART_HorizontalScrollBar" Cursor="Arrow" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Grid.Column="0" Grid.Row="1" AutomationProperties.AutomationId="HorizontalScrollBar" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Value="{Binding Path=HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" Orientation="Horizontal" ViewportSize="{TemplateBinding ViewportWidth}" Style="{StaticResource HorizontalScrollBarStyle}"/>
        </Grid>
    </ControlTemplate>
    <ControlTemplate x:Key="ListBoxControlTemplate" TargetType="{x:Type ListBox}">
        <Border x:Name="Bd" SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="1">
            <ScrollViewer Padding="{TemplateBinding Padding}" Focusable="false" Template="{StaticResource ScrollViewerControlTemplate}">
                <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
            </ScrollViewer>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
            </Trigger>
            <Trigger Property="IsGrouping" Value="true">
                <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <Style x:Key="ListBoxStyle" TargetType="{x:Type ListBox}">
        <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template" Value="{StaticResource ListBoxControlTemplate}" />
    </Style>



    <!-- Style for Button -->
    <Style TargetType="Button" x:Key="ButtonStyle">
        <Setter Property="IsEnabled" Value="true" />
        <Setter Property="IsTabStop" Value="true" />
        <Setter Property="MinWidth" Value="5" />
        <Setter Property="MinHeight" Value="5" />
        <Setter Property="Margin" Value="0" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Cursor" Value="Arrow" />
        <Setter Property="Padding" Value="20,0,20,0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid>

                        <Border x:Name="outer" CornerRadius="3,3,3,3"
								BorderThickness="1" BorderBrush="{StaticResource DistinctFilterButtonOuterBorderBrush}">
                            <Border x:Name="inner" CornerRadius="2,2,2,2" BorderThickness="1"
									BorderBrush="{StaticResource DistinctFilterButtonInnerBorderBrush}">
                                <Border x:Name="innerMost" CornerRadius="1,1,1,1"  Background="{StaticResource DistinctFilterButtonInnerMostBackground}">
                                    <ContentPresenter VerticalAlignment="Center"
											HorizontalAlignment="Center"
											Content="{TemplateBinding Content}"
											ContentTemplate="{TemplateBinding ContentTemplate}"
											Margin="6,2" />
                                </Border>
                            </Border>
                        </Border>
                        <Rectangle Stroke="{StaticResource DistinctFilterButtonFocusVisualStroke}" StrokeThickness="1" Margin="0" RadiusX="3"
								RadiusY="3" Fill="{StaticResource DistinctFilterButtonFocusVisualFill}" x:Name="FocusVisual"
								Visibility="Collapsed" />
                        <Rectangle x:Name="DisabledVisual" Visibility="Collapsed" RadiusX="3"
								RadiusY="3" Fill="{StaticResource DistinctFilterButtonDisabledVisualFill}" IsHitTestVisible="false" />
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="innerMost" Property="Background" Value="{StaticResource GridViewScrollViewerHorizontalThumbMouseOverBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="innerMost" Property="Background" Value="{StaticResource GridViewScrollViewerHorizontalThumbMouseOverBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="DisabledVisual" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <Trigger Property="IsFocused" Value="False">
                            <Setter TargetName="FocusVisual" Property="Visibility" Value="Visible" />
                        </Trigger>
                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="DistinctFilterControlTemplate" TargetType="grid:FilteringDropDown">
        <Grid>

            <Grid.Resources>
                <telerik:BooleanToVisibilityConverter
					x:Key="BooleanToVisibilityConverter" />
            </Grid.Resources>

            <ToggleButton x:Name="PART_DropDownButton" Width="20" Height="20">
                <ToggleButton.Template>
                    <ControlTemplate TargetType="ToggleButton">
                        <ContentPresenter />
                    </ControlTemplate>
                </ToggleButton.Template>

                <Grid Width="11" Height="12" Background="Transparent">

                    <Path Stretch="Fill" Fill="{StaticResource DistinctFilterFunnelFill}"  Stroke="{x:Null}" Data="M0,0 L11,0 11,1 10,1 10,2 9,2 9,3 8,3 8,3.9999999 7,3.9999999 7,12 4,12 4,3.9999999 3.0000001,3.9999999 3.0000001,3 2,3 2,2 1,2 1,1 0,1 z"/>

                    <Path Stretch="Fill" Stroke="{x:Null}" VerticalAlignment="Top" Margin="0,1,0,0" Width="5" Height="3" Data="M0,0 L1,0 2,0 3,0 4,0 5,0 5.9999999,0 7,0 7,0.99999996 5.9999999,0.99999996 5,0.99999996 5.9999999,1.0000001 5.9999999,2 5,2 4.981,2 4.981,3 4,3 3.9809999,3 3.9809999,4 2.9809999,4 2.9809999,3 2,3 2,2 1,2&#xa;1,1.0000001 0,1.0000001 z" Fill="#FFFFFFFF"
						Visibility="{TemplateBinding FilteringIndicatorVisibility}"   SnapsToDevicePixels="True"
                         />

                </Grid>
            </ToggleButton>




            <Popup x:Name="PART_DropDownPopup" StaysOpen="False">


                <Border BorderThickness="1" BorderBrush="{StaticResource DistinctFilterDropDownPopupBorderBrush}" 
                                            Background="{StaticResource DistinctFilterDropDownPopupBackground}"
                                            Padding="5">

                    <StackPanel Width="200">
                        <Button x:Name="PART_ClearFilterButton" 
								telerik:LocalizationManager.ResourceKey="GridViewClearFilter" Margin="0,2,0,2"  />
                        <StackPanel x:Name="PART_DistinctFilter">
                            <CheckBox x:Name="PART_SelectAllCheckBox" 
								telerik:LocalizationManager.ResourceKey="GridViewFilterSelectAll" Margin="0,2,0,2" Style="{StaticResource CheckBoxItem}"/>


                            <grid:DistinctValuesList 
								
                                    MaxHeight="250"
								ScrollViewer.HorizontalScrollBarVisibility="Hidden"
                                Style="{StaticResource ListBoxStyle}"
                                    
                                    x:Name="PART_DistinctValuesList"
								DataContext="{TemplateBinding FilterDescription}"
								ItemsSource="{Binding DistinctValues}">

                                <grid:DistinctValuesList.ItemContainerStyle>
                                    <Style TargetType="grid:CheckBoxItem">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate
														TargetType="grid:CheckBoxItem">
                                                    <Grid>
                                                        <CheckBox x:Name="Check"
																IsChecked="{TemplateBinding IsSelected}"
																DataContext="{TemplateBinding Content}"
																Content="{Binding ConvertedValue}" Style="{StaticResource CheckBoxItem}" />
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </grid:DistinctValuesList.ItemContainerStyle>
                            </grid:DistinctValuesList>

                        </StackPanel>
                        <StackPanel Width="200" 
								DataContext="{TemplateBinding FilterDescription}">
                            <StackPanel.Resources>
                                <grid:FilterOperatorConverter
										x:Key="FilterOperatorConverter" />

                                <DataTemplate x:Key="ActionTemplate">
                                    <TextBlock
											Text="{Binding Converter={StaticResource FilterOperatorConverter}}" />
                                </DataTemplate>
                            </StackPanel.Resources>
                            <TextBlock telerik:LocalizationManager.ResourceKey="GridViewFilterShowRowsWithValueThat" Margin="0,2,0,2" TextWrapping="Wrap" Width="200" />



                            <grid:RadComboBox 						
                                
										x:Name="PART_Filter1ComboBox" Margin="0,2,0,2" 
												  ItemTemplate="{StaticResource ActionTemplate}" telerik:StyleManager.Theme="{StaticResource Theme}"
												  ItemsSource="{Binding AvailableActions}" 
												  SelectedItem="{Binding Filter1.Operator, Mode=OneWay}"/>
                            <TextBox x:Name="PART_Filter1TextBox" Text="{Binding Filter1.Value, Mode=OneWay}" Margin="0,2,0,2" Style="{StaticResource TextBoxStyle}" />


                            <TextBlock telerik:LocalizationManager.ResourceKey="GridViewFilterAnd" Margin="0,2,0,2" TextWrapping="Wrap" Width="200" />



                            <grid:RadComboBox 						
                                
												x:Name="PART_Filter2ComboBox" Margin="0,2,0,2" 
												  ItemTemplate="{StaticResource ActionTemplate}" telerik:StyleManager.Theme="{StaticResource Theme}"
												  ItemsSource="{Binding AvailableActions}" 
												  SelectedItem="{Binding Filter1.Operator, Mode=OneWay}"/>
                            <TextBox x:Name="PART_Filter2TextBox" Text="{Binding Filter2.Value, Mode=OneWay}" Margin="0,2,0,2" Style="{StaticResource TextBoxStyle}"/>
                        </StackPanel>
                        <Button x:Name="PART_ApplyFilterButton" telerik:LocalizationManager.ResourceKey="GridViewFilter" Margin="0,2,0,2"  />
                    </StackPanel>
                </Border>

            </Popup>
        </Grid>
    </ControlTemplate>

    <Style TargetType="grid:FilteringDropDown"
		
        x:Key="{telerik:ThemeResourceKey ThemeType=local:MyCustomTheme, ElementType=grid:FilteringDropDown}"
         >
        <Setter Property="Template" Value="{StaticResource DistinctFilterControlTemplate}"/>

        <Setter Property="Foreground" Value="#FF333333" />
        <Setter Property="FontWeight" Value="Normal" />
        <Setter Property="FontStyle" Value="Normal" />
        <Setter Property="FontSize" Value="11" />
    </Style>
    
</ResourceDictionary>