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

  <!-- string resources -->
  <res:Strings x:Key="LocStrings" x:Name="LocStrings" />

  <!-- ColumnFilterEditor template -->
  <Style TargetType="local:ColumnFilterEditor">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="local:ColumnFilterEditor">
          <Border Background="{TemplateBinding Background}"
                  BorderBrush="{TemplateBinding BorderBrush}"
                  BorderThickness="{TemplateBinding BorderThickness}"
                  CornerRadius="0 0 4 4">

            <Grid x:Name="LayoutRoot" >
              <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
              </Grid.RowDefinitions>

              <!-- value/condition editors -->
              <Grid>

                <!-- value filter editor -->
                <Grid x:Name="_edtValue" >
                  <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition />
                  </Grid.RowDefinitions>

                  <CheckBox
                      x:Name="_chkSelectAll"
                      Content="{Binding Path=SelectAll, Source={StaticResource LocStrings}}"
                      Margin="10 6 6 3"
                      FontWeight="Bold"
                      HorizontalAlignment="Left" />

                  <ListBox Grid.Row="1"
                      x:Name="_lbValues"
                      Margin="6 0 6 6"
                      VerticalAlignment="Top"
                      MinHeight="50"
                      MaxHeight="150" >
                  </ListBox>
                </Grid>

                <!-- condition editor -->
                <Grid x:Name="_edtCondition" >
                  <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto" MinWidth="150" />
                    <ColumnDefinition Width="auto" MinWidth="80" />
                  </Grid.ColumnDefinitions>
                  <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="auto" />
                  </Grid.RowDefinitions>

                  <TextBlock
                      Text="{Binding ShowItems, Source={StaticResource LocStrings}}"
                      Grid.ColumnSpan="2"
                      Margin="6 6 0 0"
                      VerticalAlignment="Center" />

                  <ComboBox x:Name="_cmbCond1" DisplayMemberPath="Label" Grid.Row="1" Margin="6 2" >
                      <ComboBox.ItemTemplate>
                          <DataTemplate>
                              <TextBlock Text="{Binding Label}"/>
                          </DataTemplate>
                      </ComboBox.ItemTemplate>
                  </ComboBox>
                  <TextBox x:Name="_txtCond1" Grid.Row="1" Grid.Column="1" Margin="6 2" />
                  <DatePicker x:Name="_dateCond1" Grid.Row="1" Grid.Column="1" Margin="6 2" Visibility="Collapsed" />
                  <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.ColumnSpan="2" Margin="6 2" >
                    <RadioButton
                        x:Name="_btnAnd"
                        Content="{Binding And, Source={StaticResource LocStrings}}"
                        Margin="0 0 12 0"
                        VerticalAlignment="Center" />
                    <RadioButton
                        Content="{Binding Or, Source={StaticResource LocStrings}}"
                        VerticalAlignment="Center" />
                  </StackPanel>

                 <ComboBox x:Name="_cmbCond2"  DisplayMemberPath="Label" Grid.Row="3" Margin="6 2" >
                      <ComboBox.ItemTemplate>
                          <DataTemplate>
                              <TextBlock Text="{Binding Label}"/>
                          </DataTemplate>
                      </ComboBox.ItemTemplate>
                  </ComboBox>
                  <TextBox x:Name="_txtCond2" Grid.Row="3" Grid.Column="1" Margin="6 2" />
                  <DatePicker x:Name="_dateCond2" Grid.Row="3" Grid.Column="1" Margin="6 2" Visibility="Collapsed" />  
                </Grid>
              </Grid>

              <!-- commands -->
              <Grid Grid.Row="1" >
                <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="auto" />
                  <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <local:HyperlinkButton
                    x:Name="_btnToggleFilter"
                    Content="{Binding Conditions, Source={StaticResource LocStrings}}"
                    Margin="6 6 12 6"
                    VerticalContentAlignment="Center"
                    HorizontalAlignment="Left" />
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 6" Grid.Column="1" >
                  <Button
                      x:Name="_btnApply"
                      Content="{Binding Apply, Source={StaticResource LocStrings}}"
                      Margin="2 0" Padding="6 0" />
                  <Button
                      x:Name="_btnClear"
                      Content="{Binding Clear, Source={StaticResource LocStrings}}"
                      Margin="2 0" Padding="6 0" />
                  <Button
                      x:Name="_btnCancel"
                      Content="{Binding Cancel, Source={StaticResource LocStrings}}"
                      Margin="2 0" Padding="6 0" />
                </StackPanel>
              </Grid>
            </Grid>
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <!-- HyperlinkButton template -->
  <Style TargetType="local:HyperlinkButton">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="Button" >
          <TextBlock Foreground="#ff73a9d8" Cursor="Hand" >
            <ContentPresenter />
          </TextBlock>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <Trigger Property="IsMouseOver" Value="True" >
        <Setter Property="TextBlock.TextDecorations" Value="Underline" />
      </Trigger>
    </Style.Triggers>
  </Style>
</ResourceDictionary>
