MESCIUS InputMan for WPF 3.0J
ComboBox.xaml

ComboBox.xaml では、コンボコントロールの外観を定義します。

ComboBox.xaml の内容は以下のとおりです。

ComboBox.xaml の内容
<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:im="clr-namespace:GrapeCity.Windows.InputMan;assembly=GrapeCity.WPF.InputMan"
  xmlns:imp="clr-namespace:GrapeCity.Windows.InputMan.Primitives;assembly=GrapeCity.WPF.InputMan"
  xmlns:sys="clr-namespace:System;assembly=mscorlib">

  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/GrapeCity.WPF.InputMan;component/Themes/Generic/Common.xaml"/>
    <ResourceDictionary Source="/GrapeCity.WPF.InputMan;component/Themes/Generic/Base.xaml"/>
    <ResourceDictionary Source="/GrapeCity.WPF.InputMan;component/Themes/Generic/SideButton.xaml"/>
  </ResourceDictionary.MergedDictionaries>

  <Style x:Key="GcComboBoxFocusVisual">
    <Setter Property="Control.Template">
      <Setter.Value>
        <ControlTemplate>
          <Rectangle Margin="3,3,21,3"  StrokeThickness="1" Stroke="Black" StrokeDashArray="1 2" SnapsToDevicePixels="true"/>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <LinearGradientBrush x:Key="EditorBorderBrush" EndPoint="0.5,1" StartPoint="0.5,0">
    <GradientStop Color="#FFA3AEB9" Offset="0"/>
    <GradientStop Color="#FF8399A9" Offset="0.375"/>
    <GradientStop Color="#FF718597" Offset="0.375"/>
    <GradientStop Color="#FF617584" Offset="1"/>
  </LinearGradientBrush>

  <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" x:Key="ButtonBorderKey">
    <GradientStop Color="#FFA3AEB9" Offset="0"/>
    <GradientStop Color="#FF8399A9" Offset="0.375"/>
    <GradientStop Color="#FF718597" Offset="0.375"/>
    <GradientStop Color="#FF617584" Offset="1"/>
  </LinearGradientBrush>

  <Style TargetType="imp:ComboDropDownWindow" x:Key="ComboDropDownWindowStyle">
    <Setter Property="AllowResize" Value="True"/>
    <Setter Property="ResizeBarBackground" Value="#FFE9EEF4"/>
    <Setter Property="BorderBrush" Value="{StaticResource EditorBorderBrush}"/>
    <Setter Property="BorderThickness" Value="1"/>
  </Style>

  <Style TargetType="TextBox" x:Key="ComboEditTextBoxStyle">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="TextBox" >
          <ScrollViewer x:Name="PART_ContentHost"
                          Padding="{TemplateBinding Padding}"
                          Foreground="{TemplateBinding Foreground}"
                          Background="{TemplateBinding Background}"
                          Margin="0"
                  HorizontalScrollBarVisibility="Hidden"
                  VerticalScrollBarVisibility="Hidden"
                  BorderThickness="0"
                  IsTabStop="False"
                 />
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="BorderThickness" Value="0"></Setter>
    <Setter Property="Margin" Value="0"></Setter>
  </Style>

  <ControlTemplate x:Key="ComboBoxEditableTemplate" TargetType="im:GcComboBox">
    <Grid>
      <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="CommonStates">
          <VisualState x:Name="Normal"/>
          <VisualState x:Name="ReadOnly"/>
          <VisualState x:Name="MouseOver"/>
          <VisualState x:Name="Disabled">
            <Storyboard>
              <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="DisabledBorder">
                <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
              </DoubleAnimationUsingKeyFrames>
            </Storyboard>
          </VisualState>
        </VisualStateGroup>
        <VisualStateGroup x:Name="ActiveStates">
          <VisualState x:Name="ActiveDropDown">
          </VisualState>
          <VisualState x:Name="Active">
          </VisualState>
          <VisualState x:Name="Inactive">
          </VisualState>
        </VisualStateGroup>
        <VisualStateGroup x:Name="SpinButtonStates">
          <VisualState x:Name="SpinButtonVisible">
            <Storyboard>
              <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="SpinButtonPanel">
                <DiscreteObjectKeyFrame KeyTime="0">
                  <DiscreteObjectKeyFrame.Value>
                    <Visibility>Visible</Visibility>
                  </DiscreteObjectKeyFrame.Value>
                </DiscreteObjectKeyFrame>
              </ObjectAnimationUsingKeyFrames>
            </Storyboard>
          </VisualState>
          <VisualState x:Name="SpinButtonCollapsed">
          </VisualState>
        </VisualStateGroup>
        <VisualStateGroup x:Name="DropDownButtonStates">
          <VisualState x:Name="DropDownButtonVisible"/>
          <VisualState x:Name="DropDownButtonCollapsed">
            <Storyboard>
              <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DropDownButton">
                <DiscreteObjectKeyFrame KeyTime="0">
                  <DiscreteObjectKeyFrame.Value>
                    <Visibility>Collapsed</Visibility>
                  </DiscreteObjectKeyFrame.Value>
                </DiscreteObjectKeyFrame>
              </ObjectAnimationUsingKeyFrames>
            </Storyboard>
          </VisualState>
        </VisualStateGroup>
      </VisualStateManager.VisualStateGroups>

      <Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" 
          BorderThickness="{TemplateBinding BorderThickness}"
            SnapsToDevicePixels="True"
          CornerRadius="1" Opacity="1">
        <Grid>
          <Rectangle x:Name="EnabledVisualElement" Opacity="1" Fill="{TemplateBinding EditableBackground}"/>
          <Rectangle x:Name="DisabledBorder" Fill="{TemplateBinding DisabledBackground}" StrokeThickness="0" IsHitTestVisible="False" Opacity="0"/>
          <Grid>
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="*"/>
              <ColumnDefinition Width="Auto"/>
              <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <TextBox x:Name="PART_EditHost" IsReadOnly="{Binding Path=IsReadOnly,RelativeSource={RelativeSource TemplatedParent}}"
                      Style="{StaticResource ComboEditTextBoxStyle}"
                      HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                      VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                      Foreground="{TemplateBinding Foreground}"
                      Background="{TemplateBinding EditableBackground}"
                      Padding="{TemplateBinding Padding}"
                      >
            </TextBox>
            <Grid Grid.Column="1" x:Name="SpinButtonPanel" Visibility="Collapsed" Margin="0,1,1,1">
              <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
              </Grid.RowDefinitions>
              <imp:SpinButton Command="im:GcComboBox.SpinUpCommand" Content="{StaticResource UpArrowGeometry}" />
              <imp:SpinButton Command="im:GcComboBox.SpinDownCommand" Grid.Row="1" Content="{StaticResource DownArrowGeometry}"/>
            </Grid>

            <imp:DropDownButton x:Name="DropDownButton" Grid.Column="2"
                          IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"/>

          </Grid>
        </Grid>
      </Border>
      <imp:ComboDropDownWindow x:Name="PART_Popup"  Width="{Binding Path=DropDownWidth, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"  
          Style="{TemplateBinding DropDownWindowStyle}" TargetElementValue="{Binding Path=SelectedItem, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}">
        <im:GcListBox x:Name="PART_DropDownChild"
                BorderThickness="0"
                KeyboardNavigation.TabNavigation="Local"
                ItemCheckBoxVisibility="{TemplateBinding ItemCheckBoxVisibility}"
                ItemContainerStyle="{TemplateBinding ItemContainerStyle}"
                ItemTemplate="{TemplateBinding ItemTemplate}"
                IsSynchronizedWithCurrentItem="{TemplateBinding IsSynchronizedWithCurrentItem}"
                AutoGenerateColumns="{TemplateBinding AutoGenerateColumns}"
                UseMultipleColumn="{TemplateBinding UseMultipleColumn}"
                CanUserResizeColumns="{TemplateBinding CanUserResizeColumns}"
                CanUserSortColumns="{TemplateBinding CanUserSortColumns}"
                CheckOnClick="{TemplateBinding CheckOnClick}"
                VerticalGridLineBrush="{TemplateBinding VerticalGridLineBrush}"
                VerticalGridLineStyle="{TemplateBinding VerticalGridLineStyle}"
                HorizontalGridLineBrush="{TemplateBinding HorizontalGridLineBrush}"
                HorizontalGridLineStyle="{TemplateBinding HorizontalGridLineStyle}"
                ItemsSource="{TemplateBinding ItemsSource}"
                DisplayMemberPath="{TemplateBinding ContentPath}"
                AlternationCount="{TemplateBinding AlternationCount}"
                AlternatingItemBackground="{TemplateBinding AlternatingItemBackground}"
                ItemBackground="{TemplateBinding ItemBackground}"
                SelectedItem="{Binding ElementName=PART_Popup, Path=DropDownValue, Mode=TwoWay}"/>
      </imp:ComboDropDownWindow>
    </Grid>
    <ControlTemplate.Triggers>
      <Trigger Property="IsEnabled" Value="False">
        <Setter TargetName="PART_EditHost" Property="Background" Value="Transparent"></Setter>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>

  <ControlTemplate x:Key="ComboBoxUneditableTemplate" TargetType="im:GcComboBox">
    <Grid>
      <Grid.Resources>
        <Style x:Key="comboToggleStyle" TargetType="ToggleButton">
          <Setter Property="Foreground" Value="#FF333333"/>
          <Setter Property="Background" Value="#FF1F3B53"/>
          <Setter Property="FocusVisualStyle" Value="{StaticResource GcComboBoxFocusVisual}"></Setter>
          <Setter Property="BorderBrush">
            <Setter.Value>
              <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="#FFA3AEB9" Offset="0"/>
                <GradientStop Color="#FF8399A9" Offset="0.375"/>
                <GradientStop Color="#FF718597" Offset="0.375"/>
                <GradientStop Color="#FF617584" Offset="1"/>
              </LinearGradientBrush>
            </Setter.Value>
          </Setter>
          <Setter Property="BorderThickness" Value="1"/>
          <Setter Property="Padding" Value="3"/>
          <Setter Property="KeyboardNavigation.AcceptsReturn" Value="False"></Setter>
          <Setter Property="Template">
            <Setter.Value>
              <ControlTemplate TargetType="ToggleButton">
                <Grid>
                  <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStates">
                      <VisualState x:Name="Normal"/>
                      <VisualState x:Name="MouseOver">
                        <Storyboard>
                          <DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundOverlay" Storyboard.TargetProperty="Opacity" To="1"/>
                          <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" To="#7FFFFFFF"/>
                          <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" To="#CCFFFFFF"/>
                          <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" To="#F2FFFFFF"/>
                        </Storyboard>
                      </VisualState>
                      <VisualState x:Name="Pressed">
                        <Storyboard>
                          <DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundOverlay2" Storyboard.TargetProperty="Opacity" To="1"/>
                          <DoubleAnimation Duration="0" Storyboard.TargetName="Highlight" Storyboard.TargetProperty="(UIElement.Opacity)" To="1"/>
                          <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" To="#E5FFFFFF"/>
                          <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" To="#BCFFFFFF"/>
                          <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" To="#6BFFFFFF"/>
                          <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" To="#F2FFFFFF"/>
                        </Storyboard>
                      </VisualState>
                      <VisualState x:Name="Disabled" />
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="CheckStates">
                      <VisualState x:Name="Checked">
                        <Storyboard>
                          <DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundOverlay3" Storyboard.TargetProperty="(UIElement.Opacity)" To="1"/>
                          <DoubleAnimation Duration="0" Storyboard.TargetName="Highlight" Storyboard.TargetProperty="(UIElement.Opacity)" To="1"/>
                          <DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundGradient2" Storyboard.TargetProperty="(UIElement.Opacity)" To="1"/>
                          <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient2" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" To="#E5FFFFFF"/>
                          <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient2" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" To="#BCFFFFFF"/>
                          <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient2" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" To="#6BFFFFFF"/>
                          <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient2" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" To="#F2FFFFFF"/>
                        </Storyboard>
                      </VisualState>
                      <VisualState x:Name="Unchecked"/>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="FocusStates">
                      <VisualState x:Name="Focused">
                        <Storyboard>
                          <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility" Duration="0">
                            <DiscreteObjectKeyFrame KeyTime="0">
                              <DiscreteObjectKeyFrame.Value>
                                <Visibility>Visible</Visibility>
                              </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                          </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                      </VisualState>
                      <VisualState x:Name="Unfocused" />
                    </VisualStateGroup>
                  </VisualStateManager.VisualStateGroups>
                  <Rectangle x:Name="Background" RadiusX="3" RadiusY="3" Fill="{TemplateBinding Background}" StrokeThickness="{TemplateBinding BorderThickness}" Stroke="{TemplateBinding BorderBrush}"/>
                  <Rectangle x:Name="BackgroundOverlay" Opacity="0" RadiusX="3" RadiusY="3" Fill="#FF448DCA" StrokeThickness="{TemplateBinding BorderThickness}" Stroke="#00000000"/>
                  <Rectangle x:Name="BackgroundOverlay2" Opacity="0" RadiusX="3" RadiusY="3" Fill="#FF448DCA" StrokeThickness="{TemplateBinding BorderThickness}" Stroke="#00000000"/>
                  <Rectangle x:Name="BackgroundGradient" RadiusX="2" RadiusY="2" StrokeThickness="1" Margin="{TemplateBinding BorderThickness}" Stroke="#FFFFFFFF">
                    <Rectangle.Fill>
                      <LinearGradientBrush StartPoint=".7,0" EndPoint=".7,1">
                        <GradientStop Color="#FFFFFFFF" Offset="0" />
                        <GradientStop Color="#F9FFFFFF" Offset="0.375" />
                        <GradientStop Color="#E5FFFFFF" Offset="0.625" />
                        <GradientStop Color="#C6FFFFFF" Offset="1" />
                      </LinearGradientBrush>
                    </Rectangle.Fill>
                  </Rectangle>
                  <Rectangle Opacity="0" x:Name="BackgroundOverlay3" RadiusX="3" RadiusY="3" Fill="#FF448DCA" StrokeThickness="{TemplateBinding BorderThickness}" Stroke="#00000000"/>
                  <Rectangle Opacity="0" x:Name="BackgroundGradient2" RadiusX="2" RadiusY="2" StrokeThickness="1" Margin="{TemplateBinding BorderThickness}" Stroke="#FFFFFFFF">
                    <Rectangle.Fill>
                      <LinearGradientBrush StartPoint=".7,0" EndPoint=".7,1">
                        <GradientStop Color="#FFFFFFFF" Offset="0" />
                        <GradientStop Color="#F9FFFFFF" Offset="0.375" />
                        <GradientStop Color="#E5FFFFFF" Offset="0.625" />
                        <GradientStop Color="#C6FFFFFF" Offset="1" />
                      </LinearGradientBrush>
                    </Rectangle.Fill>
                  </Rectangle>
                  <Rectangle x:Name="Highlight" RadiusX="2" RadiusY="2" Opacity="0" IsHitTestVisible="false" Stroke="#FF6DBDD1" StrokeThickness="1" Margin="{TemplateBinding BorderThickness}" />
                  <ContentPresenter
                            x:Name="contentPresenter"
                            Content="{TemplateBinding Content}"
                            ContentTemplate="{TemplateBinding ContentTemplate}"
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                            Margin="{TemplateBinding Padding}"/>
                  <Rectangle x:Name="FocusVisualElement" RadiusX="3.5" Margin="1"  RadiusY="3.5" Stroke="#FF6DBDD1" StrokeThickness="1" Visibility="Collapsed" IsHitTestVisible="false" />
                </Grid>
              </ControlTemplate>
            </Setter.Value>
          </Setter>
        </Style>
        <Style x:Key="spinButtonStyle" TargetType="{x:Type imp:SpinButton}">
          <Setter Property="Background" Value="#FF1F3B53"/>
          <Setter Property="Foreground" Value="#FF000000"/>
          <Setter Property="Padding" Value="3"/>
          <Setter Property="BorderThickness" Value="1"/>
          <Setter Property="BorderBrush" Value="{StaticResource ButtonBorderKey}"/>
          <Setter Property="Width" Value="17"/>
          <Setter Property="Template">
            <Setter.Value>
              <ControlTemplate TargetType="imp:SpinButton">
                <Grid>
                  <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStates">
                      <VisualState x:Name="Normal"/>
                      <VisualState x:Name="MouseOver">
                        <Storyboard>
                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundAnimation">
                            <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                          </DoubleAnimationUsingKeyFrames>
                          <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient">
                            <SplineColorKeyFrame KeyTime="0" Value="#F2FFFFFF"/>
                          </ColorAnimationUsingKeyFrames>
                          <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient">
                            <SplineColorKeyFrame KeyTime="0" Value="#CCFFFFFF"/>
                          </ColorAnimationUsingKeyFrames>
                          <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient">
                            <SplineColorKeyFrame KeyTime="0" Value="#7FFFFFFF"/>
                          </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                      </VisualState>
                      <VisualState x:Name="Pressed">
                        <Storyboard>
                          <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="Background">
                            <SplineColorKeyFrame KeyTime="0" Value="#FF6DBDD1"/>
                          </ColorAnimationUsingKeyFrames>
                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundAnimation">
                            <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                          </DoubleAnimationUsingKeyFrames>
                          <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient">
                            <SplineColorKeyFrame KeyTime="0" Value="#D8FFFFFF"/>
                          </ColorAnimationUsingKeyFrames>
                          <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient">
                            <SplineColorKeyFrame KeyTime="0" Value="#C6FFFFFF"/>
                          </ColorAnimationUsingKeyFrames>
                          <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient">
                            <SplineColorKeyFrame KeyTime="0" Value="#8CFFFFFF"/>
                          </ColorAnimationUsingKeyFrames>
                          <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)" Storyboard.TargetName="BackgroundGradient">
                            <SplineColorKeyFrame KeyTime="0" Value="#3FFFFFFF"/>
                          </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                      </VisualState>
                      <VisualState x:Name="Disabled">
                        <Storyboard>
                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="DisabledVisualElement">
                            <SplineDoubleKeyFrame KeyTime="0" Value=".55"/>
                          </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                      </VisualState>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="FocusStates">
                      <VisualState x:Name="Focused">
                        <Storyboard>
                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualElement">
                            <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                          </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                      </VisualState>
                      <VisualState x:Name="Unfocused"/>
                    </VisualStateGroup>
                  </VisualStateManager.VisualStateGroups>
                  <Border x:Name="Background" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="White" CornerRadius="3">
                    <Grid Background="{TemplateBinding Background}" Margin="1">
                      <Border x:Name="BackgroundAnimation" Background="#FF448DCA" Opacity="0"/>
                      <Rectangle x:Name="BackgroundGradient">
                        <Rectangle.Fill>
                          <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0">
                            <GradientStop Color="#FFFFFFFF" Offset="0"/>
                            <GradientStop Color="#F9FFFFFF" Offset="0.375"/>
                            <GradientStop Color="#E5FFFFFF" Offset="0.625"/>
                            <GradientStop Color="#C6FFFFFF" Offset="1"/>
                          </LinearGradientBrush>
                        </Rectangle.Fill>
                      </Rectangle>
                    </Grid>
                  </Border>
                  <Path x:Name="PART_UpArrow" 
                      Fill="{TemplateBinding Foreground}" 
                      Data="{TemplateBinding Content}"
                      Margin="{TemplateBinding Padding}"           
                      HorizontalAlignment="Center" 
                      VerticalAlignment="Center" 
                      IsHitTestVisible="False"/>
                  <Rectangle x:Name="DisabledVisualElement" Fill="#FFFFFFFF" IsHitTestVisible="false" Opacity="0" RadiusY="3" RadiusX="3"/>
                  <Rectangle x:Name="FocusVisualElement" IsHitTestVisible="false" Margin="1" Opacity="0" RadiusY="2" RadiusX="2" Stroke="#FF6DBDD1" StrokeThickness="1"/>
                </Grid>
              </ControlTemplate>
            </Setter.Value>
          </Setter>
        </Style>
      </Grid.Resources>

      <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="CommonStates">
          <VisualState x:Name="Normal" />
          <VisualState x:Name="MouseOver" />
          <VisualState x:Name="ReadOnly" />
          <VisualState x:Name="Disabled">
            <Storyboard>
              <DoubleAnimation Duration="0" Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="(UIElement.Opacity)" To=".55"/>
            </Storyboard>
          </VisualState>
        </VisualStateGroup>
        <VisualStateGroup x:Name="SpinButtonStates">
          <VisualState x:Name="SpinButtonVisible">
            <Storyboard>
              <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="SpinButtonPanel">
                <DiscreteObjectKeyFrame KeyTime="0">
                  <DiscreteObjectKeyFrame.Value>
                    <Visibility>Visible</Visibility>
                  </DiscreteObjectKeyFrame.Value>
                </DiscreteObjectKeyFrame>
              </ObjectAnimationUsingKeyFrames>
            </Storyboard>
          </VisualState>
          <VisualState x:Name="SpinButtonCollapsed">
          </VisualState>
        </VisualStateGroup>
        <VisualStateGroup x:Name="DropDownButtonStates">
          <VisualState x:Name="DropDownButtonVisible"/>
          <VisualState x:Name="DropDownButtonCollapsed">
            <Storyboard>
              <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="BtnArrow">
                <DiscreteObjectKeyFrame KeyTime="0">
                  <DiscreteObjectKeyFrame.Value>
                    <Visibility>Collapsed</Visibility>
                  </DiscreteObjectKeyFrame.Value>
                </DiscreteObjectKeyFrame>
              </ObjectAnimationUsingKeyFrames>
            </Storyboard>
          </VisualState>
        </VisualStateGroup>
      </VisualStateManager.VisualStateGroups>
      <Border x:Name="ContentPresenterBorder" CornerRadius="1" Background="Transparent" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
        <Grid>
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
          </Grid.ColumnDefinitions>
          <ToggleButton x:Name="PART_DropDownToggle" 
                    Style="{StaticResource comboToggleStyle}" 
                    HorizontalAlignment="Stretch" 
                    VerticalAlignment="Stretch"  
                    Margin="0" 
                    ClickMode="Press"
                    HorizontalContentAlignment="Right" 
                    Background="{TemplateBinding Background}" 
                    Foreground="{TemplateBinding Foreground}"
                    >
            <Path x:Name="BtnArrow" Height="4" Width="8" Stretch="Uniform" Data="F1 M 301.14,-189.041L 311.57,-189.041L 306.355,-182.942L 301.14,-189.041 Z " Margin="0,0,3,0" HorizontalAlignment="Right">
              <Path.Fill>
                <SolidColorBrush x:Name="BtnArrowColor" Color="#FF333333"/>
              </Path.Fill>
            </Path>
          </ToggleButton>
          <Grid Grid.Column="1" x:Name="SpinButtonPanel" Visibility="Collapsed">
            <Grid.RowDefinitions>
              <RowDefinition/>
              <RowDefinition/>
            </Grid.RowDefinitions>
            <imp:SpinButton Style="{StaticResource spinButtonStyle}" Command="im:GcComboBox.SpinUpCommand"  Content="{StaticResource UpArrowGeometry}"/>
            <imp:SpinButton Style="{StaticResource spinButtonStyle}" Command="im:GcComboBox.SpinDownCommand" Grid.Row="1" Content="{StaticResource DownArrowGeometry}"/>
          </Grid>
          <ContentControl  x:Name="ContentControlWrapper" Foreground="{TemplateBinding Foreground}"
                   Margin="{TemplateBinding Padding}"
                   IsTabStop="False"
                   HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                   VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
            <ContentPresenter  x:Name="SelectionBoxContentPresenter"   >
            </ContentPresenter>
          </ContentControl>
        </Grid>
      </Border>
      <Rectangle x:Name="DisabledVisualElement" RadiusX="3" RadiusY="3" Fill="White" Opacity="0" IsHitTestVisible="false" />
      <Rectangle x:Name="FocusVisualElement" RadiusX="2" RadiusY="2" Margin="1"  Stroke="#FF6DBDD1" StrokeThickness="1" Opacity="0" IsHitTestVisible="false" />
      <imp:ComboDropDownWindow x:Name="PART_Popup"  Width="{Binding Path=DropDownWidth, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" 
          Style="{TemplateBinding DropDownWindowStyle}" TargetElementValue="{Binding Path=SelectedItem, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" >
        <im:GcListBox x:Name="PART_DropDownChild"
                KeyboardNavigation.TabNavigation="Local"
                BorderThickness="0"
                ItemCheckBoxVisibility="{TemplateBinding ItemCheckBoxVisibility}"
                ItemContainerStyle="{TemplateBinding ItemContainerStyle}"
                ItemTemplate="{TemplateBinding ItemTemplate}"
                IsSynchronizedWithCurrentItem="{TemplateBinding IsSynchronizedWithCurrentItem}"
                AutoGenerateColumns="{TemplateBinding AutoGenerateColumns}"
                UseMultipleColumn="{TemplateBinding UseMultipleColumn}"
                CanUserResizeColumns="{TemplateBinding CanUserResizeColumns}"
                CanUserSortColumns="{TemplateBinding CanUserSortColumns}"
                CheckOnClick="{TemplateBinding CheckOnClick}"
                VerticalGridLineBrush="{TemplateBinding VerticalGridLineBrush}"
                VerticalGridLineStyle="{TemplateBinding VerticalGridLineStyle}"
                HorizontalGridLineBrush="{TemplateBinding HorizontalGridLineBrush}"
                HorizontalGridLineStyle="{TemplateBinding HorizontalGridLineStyle}"
                ItemsSource="{TemplateBinding ItemsSource}"
                DisplayMemberPath="{TemplateBinding ContentPath}"
                AlternationCount="{TemplateBinding AlternationCount}"
                AlternatingItemBackground="{TemplateBinding AlternatingItemBackground}"
                ItemBackground="{TemplateBinding ItemBackground}"
                SelectedItem="{Binding ElementName=PART_Popup, Path=DropDownValue, Mode=TwoWay}"/>
      </imp:ComboDropDownWindow>
    </Grid>
  </ControlTemplate>

  <Style TargetType="im:GcComboBox" x:Key="GcComboBox_StyleKey">
    <Setter Property="Padding" Value="6,2,18,2" />
    <Setter Property="Background" Value="#FF1F3B53"/>
    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
    <Setter Property="BorderThickness" Value="0"/>
    <Setter Property="BorderBrush">
      <Setter.Value>
        <LinearGradientBrush EndPoint="0,20" StartPoint="0,0" MappingMode="Absolute">
          <GradientStop Color="#ABADB3" Offset="0.05"/>
          <GradientStop Color="#E2E3EA" Offset="0.07"/>
          <GradientStop Color="#E3E9EF" Offset="1"/>
        </LinearGradientBrush>
      </Setter.Value>
    </Setter>
    <Setter Property="HorizontalContentAlignment" Value="Left"/>
    <Setter Property="EditableTemplate" Value="{StaticResource ComboBoxEditableTemplate}"/>
    <Setter Property="UnEditableTemplate" Value="{StaticResource ComboBoxUneditableTemplate}"/>
    <Setter Property="DropDownWindowStyle" Value="{StaticResource ComboDropDownWindowStyle}"/>
    <Setter Property="VerticalContentAlignment" Value="Center"></Setter>
    <Style.Triggers>
      <Trigger Property="IsEditable" Value="True">
        <Setter Property="BorderThickness" Value="1"></Setter>
        <Setter Property="Padding" Value="1"></Setter>
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style TargetType="im:GcComboBox" BasedOn="{StaticResource GcComboBox_StyleKey}"/>
</ResourceDictionary>
関連トピック

 

 


© MESCIUS inc. All rights reserved.