<?xml version="1.0" encoding="utf-8"?>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:C1.Silverlight.FlexGridExcel">

    <!-- menu item with subitems -->
    <Style TargetType="local:C1MenuItem">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="Padding" Value="4,3,2,3" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:C1MenuItem">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Presenter" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Unfocused" />
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Bg" />
                                        <ColorAnimation Duration="0" To="#40FFFFFF" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="InnerBorder" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Rectangle Fill="{TemplateBinding Background}" RadiusY="2" RadiusX="2" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" />
                        <Rectangle x:Name="Bg" Opacity="0" RadiusY="2" RadiusX="2" Stroke="#8071CBF1" StrokeThickness="1">
                            <Rectangle.Fill>
                                <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                    <GradientStop Color="#34C5EBFF" Offset="0" />
                                    <GradientStop Color="#3481D8FF" Offset="1" />
                                </LinearGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <Rectangle x:Name="InnerBorder" Margin="1" RadiusY="2" RadiusX="2" Stroke="Transparent" />
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition MinWidth="24" Width="Auto" />
                                <ColumnDefinition Width="4" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="17" />
                            </Grid.ColumnDefinitions>
                            <ContentPresenter Content="{TemplateBinding Icon}" Margin="1" VerticalAlignment="Center" />
                            <ContentPresenter x:Name="Presenter" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" Grid.Column="2" Margin="{TemplateBinding Padding}" />
                            <Path Grid.Column="3" Data="M 0,0 L 4,3.5 L 0,7 Z" Fill="Black" Margin="4,0,0,0" VerticalAlignment="Center" Visibility="{TemplateBinding HasSubItems}" />
                        </Grid>
                        <Popup x:Name="PART_Popup" HorizontalOffset="{TemplateBinding ActualWidth}" IsOpen="{TemplateBinding IsSubmenuOpen}" Margin="-4,0,0,0">
                            <ContentControl x:Name="SubMenuBorder">
                                <ContentControl.Template>
                                    <ControlTemplate>
                                        <Grid Background="#FFF5F5F5">
                                            <Rectangle Fill="#F1F1F1" HorizontalAlignment="Left" RadiusY="2" RadiusX="2" Width="28" />
                                            <Rectangle Fill="#E2E3E3" HorizontalAlignment="Left" Width="1" Margin="30,0,0,0" />
                                            <Rectangle Fill="White" HorizontalAlignment="Left" Width="1" Margin="31,0,0,0" />
                                            <ContentPresenter Grid.ColumnSpan="2" Margin="1,0" />
                                        </Grid>
                                    </ControlTemplate>
                                </ContentControl.Template>
                                <ScrollViewer x:Name="SubMenuScrollViewer" VerticalScrollBarVisibility="Auto" Padding="0">
                                    <Grid>
                                        <Canvas HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
                                            <Rectangle Fill="#FFF5F5F5" Height="{Binding ActualHeight, ElementName=SubMenuBorder}" Width="{Binding ActualWidth, ElementName=SubMenuBorder}" />
                                        </Canvas>
                                        <ItemsPresenter x:Name="ItemsPresenter" Margin="2" />
                                    </Grid>
                                </ScrollViewer>
                            </ContentControl>
                        </Popup>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- excel-style filter editor -->
    <Style TargetType="local:ExcelFilterEditor">
        <Setter Property="MinWidth" Value="230" />
        <Setter Property="MinHeight" Value="230" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ExcelFilterEditor">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <Grid.Resources>
                                <Style x:Key="_sTB" TargetType="HyperlinkButton">
                                    <Setter Property="Margin" Value="2" />
                                </Style>
                                <Style x:Key="_sImg" TargetType="Image">
                                    <!--<Setter Property="Width" Value="20" />-->
                                    <Setter Property="Stretch" Value="None" />
                                    <Setter Property="VerticalAlignment" Value="Center" />
                                    <Setter Property="HorizontalAlignment" Value="Center" />
                                    <Setter Property="Margin" Value="2 0" />
                                </Style>
                                <Style x:Key="_sBtn" TargetType="Button">
                                    <Setter Property="Margin" Value="0 0 6 0" />
                                    <Setter Property="Padding" Value="2" />
                                    <Setter Property="MinWidth" Value="60" />
                                </Style>
                                <Style x:Key="_sSep" TargetType="Border">
                                    <Setter Property="BorderBrush" Value="LightGray" />
                                    <Setter Property="BorderThickness" Value=".5" />
                                    <!--<Setter Property="Margin" Value="2" />-->
                                </Style>
                            </Grid.Resources>
                            <Grid.RowDefinitions>
                                <!-- sort -->
                                <RowDefinition Height="auto" />
                                <RowDefinition Height="auto" />
                                <RowDefinition Height="auto" />
                                <!-- separator -->
                                <RowDefinition Height="auto" />
                                <!-- filter -->
                                <RowDefinition Height="auto" />
                                <RowDefinition Height="auto" />
                                <RowDefinition Height="*" />
                                <!-- separator -->
                                <RowDefinition Height="auto" />
                                <!-- buttons -->
                                <RowDefinition Height="auto" />
                                <!-- resizer -->
                                <RowDefinition Height="auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="20" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>

                            <!-- vertical separator -->
                            <Border Grid.RowSpan="9" Style="{StaticResource _sSep}" Background="WhiteSmoke" HorizontalAlignment="Stretch" />

                            <!-- sorting -->
                            <Image Source="/C1.Silverlight.FlexGridExcel.5;component/Resources/SortAscending_small.png" Style="{StaticResource _sImg}" />
                            <HyperlinkButton Name="_btnSortAsc" Content="Sort Ascending" Grid.Column="1" Style="{StaticResource _sTB}" />

                            <Image Source="/C1.Silverlight.FlexGridExcel.5;component/Resources/SortDescending_small.png" Grid.Row="1" Style="{StaticResource _sImg}" />
                            <HyperlinkButton Name="_btnSortDesc" Content="Sort Descending" Grid.Row="1" Grid.Column="1" Style="{StaticResource _sTB}" />

                            <HyperlinkButton Name="_btnSortNone" Content="Remove Sort" Grid.Row="2" Grid.Column="1" Style="{StaticResource _sTB}" />

                            <Border Grid.Row="3" Grid.Column="1" Style="{StaticResource _sSep}" />

                            <!-- filter -->
                            <Image Source="/C1.Silverlight.FlexGridExcel.5;component/Resources/ClearFilter_small.png" Grid.Row="4" Style="{StaticResource _sImg}" />
                            <HyperlinkButton Name="_btnClear" Content="Clear Filter" Grid.Row="4" Grid.Column="1" Style="{StaticResource _sTB}" />

                            <Image Grid.Row="5" Style="{StaticResource _sImg}" />
                            <HyperlinkButton Name="_btnToggleFilter" Content="Conditions &gt;&gt;" Grid.Row="5" Grid.Column="1" Style="{StaticResource _sTB}" />

                            <!-- value filter -->
                            <Border Grid.Row="6" Grid.Column="1">
                                <Grid Name="_edtValue">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="auto" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>

                                    <!-- value filter -->
                                    <Grid Margin="0 0 4 0">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition />
                                            <ColumnDefinition Width="auto" />
                                        </Grid.ColumnDefinitions>
                                        <TextBox Name="_txtValueFilter" BorderBrush="#30000000" Padding="4 0" Margin="0 4 0 0" />
                                        <Image Name="_imgFilter" Source="/C1.Silverlight.FlexGridExcel.5;component/Resources/Search1_small.png" Grid.Column="1" Style="{StaticResource _sImg}" />
                                        <Image Name="_imgClearFilter" Source="/C1.Silverlight.FlexGridExcel.5;component/Resources/Exit_small.png" Grid.Column="1" Style="{StaticResource _sImg}" Visibility="Collapsed" />
                                    </Grid>

                                    <!-- value list -->
                                    <Grid Grid.Row="1">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="auto" />
                                            <RowDefinition Height="*" />
                                        </Grid.RowDefinitions>
                                        <CheckBox Name="_chkSelectAll" Content="(Select All)" Margin="4 0 0 0" />
                                        <ListBox Name="_lbValues" BorderThickness="0" Grid.Row="1" MinHeight="50" MaxHeight="250" />
                                    </Grid>
                                </Grid>
                            </Border>

                            <!-- condition filter -->
                            <Border Grid.Row="6" Grid.Column="1">
                                <Grid Name="_edtCondition">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="10*" MinWidth="100" />
                                        <ColumnDefinition Width="8*" MinWidth="80" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="auto" />
                                        <RowDefinition Height="auto" />
                                        <RowDefinition Height="auto" />
                                        <RowDefinition Height="auto" />
                                    </Grid.RowDefinitions>

                                    <TextBlock Text="Show Items" Grid.ColumnSpan="2" Margin="6 6 0 0" VerticalAlignment="Center" />
                                    <ComboBox Name="_cmbCond1" Grid.Row="1" Padding="2 0" Margin="4 0" />
                                    <TextBox Name="_txtCond1" Grid.Row="1" Grid.Column="1" Padding="0" Margin="4 0" />
                                    <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.ColumnSpan="2" Margin="6 2">
                                        <RadioButton Name="_btnAnd" Content="And" Margin="0 0 12 0" VerticalAlignment="Center" />
                                        <RadioButton Content="Or" VerticalAlignment="Center" />
                                    </StackPanel>
                                    <ComboBox Name="_cmbCond2" Grid.Row="3" Padding="2 0" Margin="4 0" />
                                    <TextBox Name="_txtCond2" Grid.Row="3" Grid.Column="1" Padding="0" Margin="4 0" />
                                </Grid>
                            </Border>

                            <!-- OK, Cancel -->
                            <Border Grid.Row="7" Grid.Column="1" Style="{StaticResource _sSep}" />
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="8" Grid.Column="1" Margin="0 6 0 4">
                                <Button Name="_btnApply" Content="OK" Style="{StaticResource _sBtn}" />
                                <Button Name="_btnCancel" Content="Cancel" Style="{StaticResource _sBtn}" />
                            </StackPanel>

                            <!-- resizer -->
                            <Border Grid.Row="9" Grid.ColumnSpan="2" Background="WhiteSmoke">
                                <Image Name="_imgResizer" Source="/C1.Silverlight.FlexGridExcel.5;component/Resources/Resizer.png" Stretch="None" HorizontalAlignment="Right" VerticalAlignment="Bottom" Cursor="SizeNWSE" />
                            </Border>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>