<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml"
    xmlns:res="clr-namespace:C1.Silverlight.FlexGrid.Resources"
    xmlns:FlexGrid="clr-namespace:C1.WPF.FlexGrid">


    <res:C1_Silverlight_FlexSheet x:Key="Resources" />
    <!-- brushes -->
    <SolidColorBrush x:Key="RowBackground" Color="#ffffffff" />
    <SolidColorBrush x:Key="AlternatingRowBackground" Color="#ffffffff" />
    <SolidColorBrush x:Key="HeaderGridLinesBrush" Color="#FF9EB6CE" />
    <SolidColorBrush x:Key="GridLinesBrush" Color="#FFD0D7E5" />
    <SolidColorBrush x:Key="FrozenLinesBrush" Color="#e0000000" />
    <SolidColorBrush x:Key="GroupRowBackground" Color="#ffffffff" />
    <SolidColorBrush x:Key="SelectionBackground" Color="#FFEAECF5" />
    <SolidColorBrush x:Key="GridSplitterBackground" Color="#F5F5F5" />
    <SolidColorBrush x:Key="GridSplitterBorderBrush" Color="#000000" />
    <SolidColorBrush x:Key="GridSplitterRectangleFill" Color="#A9A9A9"/>
    <SolidColorBrush x:Key="FlexSheetBackground" Color="#FFFFFF" />
    <SolidColorBrush x:Key="ExcelFilterEditorBorderBrush" Color="#D3D3D3"/>
    <SolidColorBrush x:Key="ExcelFilterEditorBackground" Color="#F5F5F5"/>
    <SolidColorBrush x:Key="FormulaBarBorderBackground" Color="#D3D3D3"/>
    <SolidColorBrush x:Key="FormulaBarBorderBrush" Color="#80000000"/>
    <SolidColorBrush x:Key="FormulaTbCancelIsEnabledTrueForeground" Color="#FF0000"/>
    <SolidColorBrush x:Key="FormulaTbCancelIsEnabledFalseForeground" Color="#00008B"/>
    <SolidColorBrush x:Key="FormulaTbEnterIsEnabledTrueForeground" Color="#0000FF"/>
    <SolidColorBrush x:Key="FormulaTbEnterIsEnabledFalseForeground" Color="#00008B"/>
    <SolidColorBrush x:Key="RowHeaderSelectedBackground" Color="#FFFFD58D" />
    <SolidColorBrush x:Key="TopLeftCellBackground" Color="#FFA9C4E9"/>
    <SolidColorBrush x:Key="RowHeaderBackground" Color="#FFE4ECF7"/>
    <SolidColorBrush x:Key="TopLeftCellPolygonBackground" Color="#E0F5F5F5"/>
    <SolidColorBrush x:Key="MarqueeColor" Color="Black"/>

    <Color x:Key="GradFrom">#f0fafafa</Color>
    <Color x:Key="GgradTo">#f0d7dce1</Color>

    <LinearGradientBrush x:Key="ColumnHeaderBackground" EndPoint="0,1">
        <GradientStop Color="#FFF6FAFB" Offset="0" />
        <GradientStop Color="#FFD5DDEA" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="ColumnHeaderSelectedBackground" EndPoint="0,1">
        <GradientStop Color="#FFF8D79B" Offset="0" />
        <GradientStop Color="#FFF1C263" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="BottomRightCellBackground" EndPoint="1,1">
        <GradientStop Color="{StaticResource GgradTo}" Offset="0" />
        <GradientStop Color="{StaticResource GradFrom}" Offset="1" />
    </LinearGradientBrush>

    <!-- FontFamily -->
    <FontFamily x:Key="FlexSheetFontFamily">Arial</FontFamily>

    <!-- style for grid splitter -->
    <Style TargetType="FlexGrid:GridSplitter">
        <Setter Property="Background" Value="{StaticResource GridSplitterBackground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource GridSplitterBorderBrush}"/>
        <Setter Property="Cursor" Value="SizeWE"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="FlexGrid:GridSplitter">
                    <Border Background="{TemplateBinding Background}"
                  BorderBrush="{TemplateBinding BorderBrush}"
                  BorderThickness="{TemplateBinding BorderThickness}">
                        <Rectangle HorizontalAlignment="Center" Width="2" Margin="2" Fill="{StaticResource GridSplitterRectangleFill}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="PagePathStyle" TargetType="Path">
        <Setter Property="Stretch" Value="Fill"/>
        <Setter Property="Width" Value="6"/>
        <Setter Property="Height" Value="8"/>
    </Style>

    <Style x:Key="PageButtonStyle" TargetType="Button">
        <Setter Property="Width" Value="14"/>
        <Setter Property="Height" Value="18"/>
    </Style>

    <!-- style for main control -->
    <Style TargetType="FlexGrid:C1FlexSheet" >

        <!-- properties -->
        <!--<Setter Property="FontSize" Value="13" />-->
        <Setter Property="FontFamily" Value="{StaticResource FlexSheetFontFamily}" />
        <Setter Property="MarqueeColor" Value="{StaticResource MarqueeColor}"/>
        <Setter Property="Background" Value="{StaticResource FlexSheetBackground}" />
        <Setter Property="RowBackground" Value="{StaticResource RowBackground}"/>
        <Setter Property="AlternatingRowBackground" Value="{StaticResource AlternatingRowBackground}"/>
        <Setter Property="HeaderGridLinesBrush" Value="{StaticResource HeaderGridLinesBrush}"/>
        <Setter Property="GridLinesBrush" Value="{StaticResource GridLinesBrush}"/>
        <Setter Property="FrozenLinesBrush" Value="{StaticResource FrozenLinesBrush}"/>
        <Setter Property="GroupRowBackground" Value="{StaticResource GroupRowBackground}"/>
        <Setter Property="CursorBackground" Value="{x:Null}"/>
        <Setter Property="SelectionBackground" Value="{StaticResource SelectionBackground}"/>
        <Setter Property="RowHeaderBackground" Value="{StaticResource RowHeaderBackground}"/>
        <Setter Property="ColumnHeaderBackground" Value="{StaticResource ColumnHeaderBackground}"/>
        <Setter Property="TopLeftCellBackground" Value="{StaticResource TopLeftCellBackground}"/>
        <Setter Property="BottomRightCellBackground" Value="{StaticResource BottomRightCellBackground}"/>      
        <Setter Property="EditorBackground" Value="{x:Null}"/>
        <Setter Property="RowHeaderSelectedBackground" Value="{StaticResource RowHeaderSelectedBackground}"/>
        <Setter Property="ColumnHeaderSelectedBackground" Value="{StaticResource ColumnHeaderSelectedBackground}"/>
        <Setter Property="TopLeftCellPolygonBackground" Value="{StaticResource TopLeftCellPolygonBackground}"/>
        <!-- Excel behavior by default -->
        <Setter Property="AllowDragging" Value="None"/>
        <Setter Property="AllowSorting" Value="False"/>
        <Setter Property="AllowResizing" Value="Both"/>
        <Setter Property="ShowMarquee" Value="True"/>
        <Setter Property="GridLinesVisibility" Value="All"/>
        <Setter Property="ClipboardCopyMode" Value="ExcludeHeader"/>
        <Setter Property="ClipboardPasteMode" Value="ExcludeHeader"/>
        <Setter Property="KeyActionTab" Value="MoveAcross"/>
        <Setter Property="AreRowGroupHeadersFrozen" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="FlexGrid:C1FlexSheet">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" >
                        <Grid x:Name="_root" >
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>

                            <!-- vertical scrollbar -->
                            <ScrollBar x:Name="_sbV" Orientation="Vertical" Grid.Column="2" Grid.RowSpan="2" />

                            <Canvas x:Name="InsertLayer"  Panel.ZIndex="2" Grid.Row="1" Grid.Column="1" 
                                    HorizontalAlignment="Left" VerticalAlignment="Top" ClipToBounds="True"/>

                            <Canvas x:Name="CommentsLayer"  Panel.ZIndex="1" Grid.Row="1" Grid.Column="1" 
                                    HorizontalAlignment="Left" VerticalAlignment="Top" ClipToBounds="True"/>

                            <!-- tabs, splitter, horizontal scrollbar -->
                            <Grid x:Name="TabHolder" Grid.Row="3" Grid.ColumnSpan="2" >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="auto"/>
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <StackPanel Orientation="Horizontal" >
                                        <Button Name="BtnFirstSheet" Style="{StaticResource PageButtonStyle}" Background="{TemplateBinding Background}">
                                            <Button.Content>
                                                <Grid Height="12" Width="8">
                                                    <Rectangle Width="1" Height="8" HorizontalAlignment="Left" Fill="{TemplateBinding Foreground}"/>
                                                    <Path Data="M0,1 L1,0 L1,2 Z" Style="{StaticResource PagePathStyle}" HorizontalAlignment="Right" Fill="{TemplateBinding Foreground}"/>
                                                </Grid>
                                            </Button.Content>
                                        </Button>
                                        <Button Name="BtnPreviousSheet" Style="{StaticResource PageButtonStyle}" Background="{TemplateBinding Background}">
                                            <Button.Content>
                                                <Path Data="M0,1 L1,0 L1,2 Z" Style="{StaticResource PagePathStyle}" HorizontalAlignment="Center" Fill="{TemplateBinding Foreground}"/>
                                            </Button.Content>
                                        </Button>
                                        <Button Name="BtnNextSheet" Style="{StaticResource PageButtonStyle}" Background="{TemplateBinding Background}">
                                            <Button.Content>
                                                <Path Data="M0,0 L1,1 L0,2 Z" Style="{StaticResource PagePathStyle}" HorizontalAlignment="Center" Fill="{TemplateBinding Foreground}"/>
                                            </Button.Content>
                                        </Button>
                                        <Button Name="BtnLastSheet" Style="{StaticResource PageButtonStyle}" Background="{TemplateBinding Background}">
                                            <Button.Content>
                                                <Grid Height="12" Width="8">
                                                    <Path Data="M0,0 L1,1 L0,2 Z" Style="{StaticResource PagePathStyle}" HorizontalAlignment="Left" Fill="{TemplateBinding Foreground}"/>
                                                    <Rectangle Width="1" Height="8" HorizontalAlignment="Right" Fill="{TemplateBinding Foreground}"/>
                                                </Grid>
                                            </Button.Content>
                                        </Button>
                                    </StackPanel>
                                    <c1:C1TabControl Grid.Column="1" x:Name="Tabs" FontSize="12" 
                                        Padding="0" Margin="0 -1 0 0" IsTabStop="False" TabItemShape="{TemplateBinding TabItemShape}"
                                        TabStripPlacement="Bottom" TabStripOverlap="8" VerticalAlignment="Bottom" />
                                </Grid>
                                <FlexGrid:GridSplitter x:Name="Splitter" Width="6" Grid.Column="1" />
                                <ScrollBar x:Name="_sbH" Orientation="Horizontal" Grid.Column="2" />
                            </Grid>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- excel-style filter editor -->
    <Style TargetType="FlexGrid:ExcelFilterEditor">
        <Setter Property="MinWidth" Value="230" />
        <Setter Property="MinHeight" Value="230" />
        <Setter Property="Background" Value="{StaticResource ExcelFilterEditorBackground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ExcelFilterEditorBorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="FlexGrid:ExcelFilterEditor">
                    <Border
              Background="{TemplateBinding Background}"
              BorderBrush="{TemplateBinding BorderBrush}"
              BorderThickness="{TemplateBinding BorderThickness}" >
                        <Grid>
                            <Grid.Resources>
                                <Style x:Key="STB" TargetType="c1:HyperlinkButton" >
                                    <Setter Property="Margin" Value="2" />
                                </Style>
                                <Style x:Key="STxt" TargetType="TextBlock">
                                    <Setter Property="FontSize" Value="16"/>
                                    <Setter Property="FontFamily" Value="Segoe UI Symbol"/>
                                    <Setter Property="VerticalAlignment" Value="Center" />
                                    <Setter Property="HorizontalAlignment" Value="Center"/>
                                    <Setter Property="Margin" Value="2 0" />
                                </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="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="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" HorizontalAlignment="Stretch" />

                            <!-- sorting -->
                            <Grid Margin="2 0">
                                <Viewbox Stretch="Uniform">
                                    <Canvas Width="16" Height="16">
                                        <Path Data="M 8 7 H 6.334 L 5.794 5.396 H 3.188 L 2.659 7 H 1 L 3.626 0 H 5.423 L 8 7 z M 5.434 4.244 4.617 1.816 C 4.565 1.663 4.53 1.458 4.507 1.206 H 4.467 C 4.448 1.412 4.407 1.608 4.341 1.798 L 3.52 4.244 h 1.914 z" Fill="{TemplateBinding Foreground}"/>
                                        <Path Data="m 7 9.694 -3.835 4.26 H 6.994 V 15 H 1 V 14.287 L 4.905 10.045 H 1.29 V 9 H 6.998 V 9.694 H 7 z" Fill="IndianRed"/>
                                        <Rectangle Canvas.Left="12" Canvas.Top="0" Width="1" Height="13" Fill="{TemplateBinding Foreground}"/>
                                        <Polygon Points="10,12 12.5,15 15,12 " FillRule="NonZero" Fill="{TemplateBinding Foreground}"/>
                                    </Canvas>
                                </Viewbox>
                            </Grid>
                            <c1:HyperlinkButton Name="_btnSortAsc" Content="{Binding Path=SortAscending, Source={StaticResource Resources}}" Grid.Column="1" Style="{StaticResource STB}" />

                            <Grid Margin="2 0" Grid.Row="1">
                                <Viewbox Stretch="Uniform">
                                    <Canvas Width="16" Height="16">
                                        <Path Data="M 8 15 H 6.334 L 5.794 13.396 H 3.188 L 2.659 15 H 1 L 3.626 8 H 5.423 L 8 15 z M 5.434 12.244 4.617 9.816 C 4.565 9.663 4.53 9.458 4.507 9.206 H 4.467 C 4.448 9.412 4.407 9.607 4.341 9.798 L 3.52 12.244 h 1.914 z" Fill="{TemplateBinding Foreground}"/>
                                        <Path Data="M 7 0.693 3.165 4.954 H 6.994 V 6 H 1 V 5.287 L 4.905 1.045 H 1.29 V 0 H 6.998 V 0.693 H 7 z" Fill="IndianRed"/>
                                        <Rectangle Canvas.Left="12" Canvas.Top="0" Width="1" Height="13" Fill="{TemplateBinding Foreground}"/>
                                        <Polygon Points="15,12 10,12 12.5,15 " FillRule="NonZero" Fill="{TemplateBinding Foreground}"/>
                                    </Canvas>
                                </Viewbox>
                            </Grid>
                            <c1:HyperlinkButton Name="_btnSortDesc" Content="{Binding Path=SortDescending, Source={StaticResource Resources}}" Grid.Row="1" Grid.Column="1" Style="{StaticResource STB}" />

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

                            <!-- filter -->
                            <Grid Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Center">
                                <TextBlock FontFamily="Segoe UI Symbol" Text="&#xE16E;" Foreground="{TemplateBinding Foreground}" FontSize="12"/>
                                <TextBlock FontFamily="Segoe UI Symbol" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0,2,0,-2" FontSize="8" Text="&#xE106;" Foreground="Red"/>
                            </Grid>
                            <c1:HyperlinkButton Name="_btnClear" Content="{Binding Path=ClearFilter, Source={StaticResource Resources}}" Grid.Row="4" Grid.Column="1" Style="{StaticResource STB}" />

                            <Image Grid.Row="5" Style="{StaticResource SImg}" />
                            <c1:HyperlinkButton Name="_btnToggleFilter" Content="Conditions >>" Grid.Row="5" Grid.Column="1" Style="{StaticResource STB}" />

                            <!-- value filter -->
                            <Border Grid.Row="6" Grid.Column="1">
                                <Grid Name="_edtValue" Visibility="Collapsed">
                                    <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="{TemplateBinding BorderBrush}" Padding="4 0" Margin="0 4 0 0" />
                                        <TextBlock Name="_txtFilter" Text="&#xE094;" Grid.Column="1" Style="{StaticResource STxt}" />
                                        <TextBlock Name="_txtClearFilter" Text="&#xE221;" Grid.Column="1" Style="{StaticResource STxt}" Visibility="Collapsed" />
                                    </Grid>

                                    <!-- value list -->
                                    <Grid Grid.Row="1">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="auto" />
                                            <RowDefinition Height="*" />
                                        </Grid.RowDefinitions>
                                        <CheckBox Name="_chkSelectAll" Content="{Binding Path=SelectAll, Source={StaticResource Resources}}" 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="{Binding Path=ShowItems, Source={StaticResource Resources}}" 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" />
                                    <DatePicker x:Name="_dateCond1" Grid.Row="1" Grid.Column="1" Padding="0" Margin="4 0" Visibility="Collapsed" />
                                    <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.ColumnSpan="2" Margin="6 2" >
                                        <RadioButton Name="_btnAnd" Content="{Binding Path=And, Source={StaticResource Resources}}" Margin="0 0 12 0" VerticalAlignment="Center" />
                                        <RadioButton Content="{Binding Path=Or, Source={StaticResource Resources}}" 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" />
                                    <DatePicker x:Name="_dateCond2" Grid.Row="3" Grid.Column="1" Padding="0" Margin="4 0" Visibility="Collapsed" />
                                </Grid>
                            </Border>

                            <!-- OK, Cancel -->
                            <Border Grid.Row="7" Grid.Column="1" Style="{StaticResource SSep}" BorderBrush="{TemplateBinding BorderBrush}"/>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="8" Grid.Column="1" Margin="0 6 0 4">
                                <Button Name="_btnApply" Content="{Binding Path=OK, Source={StaticResource Resources}}" Style="{StaticResource SBtn}"/>
                                <Button Name="_btnCancel" Content="{Binding Path=Cancel, Source={StaticResource Resources}}" Style="{StaticResource SBtn}"/>
                            </StackPanel>

                            <!-- resizer -->
                            <Border Grid.Row="9" Grid.ColumnSpan="2" Background="{TemplateBinding Background}" >
                                <TextBlock Name="txtResizer" Text="&#x2834;" TextAlignment="Right" FontSize="10" FontFamily="Segoe UI Symbol" Cursor="SizeNWSE" />
                            </Border>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--FormulaBar-->
    <Style TargetType="FlexGrid:C1FormulaBar">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="FlexGrid:C1FormulaBar">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}" >
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="80" />
                                <ColumnDefinition Width="80" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <TextBlock Name="TbAddress" Text="A1" HorizontalAlignment="Center" VerticalAlignment="Center" />
                            <Border Name="TbFx" Background="{StaticResource FormulaBarBorderBackground}" Grid.Column="1" CornerRadius="10 0 0 10" BorderBrush="{StaticResource FormulaBarBorderBrush}" BorderThickness="1">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="0.25*"></ColumnDefinition>
                                        <ColumnDefinition Width="0.25*"></ColumnDefinition>
                                        <ColumnDefinition Width="0.25*"></ColumnDefinition>
                                        <ColumnDefinition Width="0.25*"></ColumnDefinition>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock x:Name="TbCancel" Grid.Column="1">
                                        <TextBlock.Style>
                                            <Style TargetType="TextBlock">
                                                <Style.Triggers>
                                                    <MultiTrigger>
                                                        <MultiTrigger.Conditions>
                                                            <Condition Property="IsMouseOver" Value="true" />
                                                            <Condition Property="IsEnabled" Value="true" />
                                                        </MultiTrigger.Conditions>
                                                        <Setter Property="Foreground" Value="{StaticResource FormulaTbCancelIsEnabledTrueForeground}"/>
                                                    </MultiTrigger>
                                                    <Trigger Property="IsEnabled" Value="false">
                                                        <Setter Property="Foreground" Value="{StaticResource FormulaTbCancelIsEnabledFalseForeground}" />
                                                    </Trigger>
                                                </Style.Triggers>
                                            </Style>
                                        </TextBlock.Style>
                                            <Path x:Name="ButtonPath" Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=TextBlock}}" StrokeThickness="1.5" Margin="4" StrokeStartLineCap="Square" StrokeEndLineCap="Square" Stretch="Uniform" VerticalAlignment="Center" HorizontalAlignment="Center" >
                                                <Path.Data>
                                                    <PathGeometry>
                                                        <PathGeometry.Figures>
                                                            <PathFigure StartPoint="0,0">
                                                                <LineSegment Point="25,25"/>
                                                            </PathFigure>
                                                            <PathFigure StartPoint="0,25">
                                                                <LineSegment Point="25,0"/>
                                                            </PathFigure>
                                                        </PathGeometry.Figures>
                                                    </PathGeometry>
                                                </Path.Data>
                                            </Path>
                                    </TextBlock>
                                    <TextBlock x:Name="TbEnter" Grid.Column="2" >
                                        <TextBlock.Style>
                                            <Style TargetType="TextBlock">
                                                <Style.Triggers>
                                                    <MultiTrigger>
                                                        <MultiTrigger.Conditions>
                                                            <Condition Property="IsMouseOver" Value="true" />
                                                            <Condition Property="IsEnabled" Value="true" />
                                                        </MultiTrigger.Conditions>
                                                        <Setter Property="Foreground" Value="{StaticResource FormulaTbEnterIsEnabledTrueForeground}"/>
                                                    </MultiTrigger>
                                                    <Trigger Property="IsEnabled" Value="false">
                                                        <Setter Property="Foreground" Value="{StaticResource FormulaTbEnterIsEnabledFalseForeground}" />
                                                    </Trigger>
                                                </Style.Triggers>
                                            </Style>
                                        </TextBlock.Style>
                                            <Path x:Name="optionMark" Data="F1 M 9.97498,1.22334L 4.6983,9.09834L 4.52164,9.09834L 0,5.19331L 1.27664,3.52165L 4.255,6.08833L 8.33331,1.52588e-005L 9.97498,1.22334 Z "  
                                                  Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=TextBlock}}" 
                                                  StrokeThickness="1" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=TextBlock}}" 
                                                  Stretch="Uniform" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="4"></Path>
                                    </TextBlock>
                                    <TextBlock Text="fx" HorizontalAlignment="Right" FontStyle="Italic" Margin="0,0,6,0" Grid.Column="3"/>
                                </Grid>
                            </Border>
                            <TextBox Name="TxtFormula" Grid.Column="2" Padding="4 0" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
