リサイズはクリックかドラッグ

Number.xaml

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

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

Number.xaml の内容
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:if="clr-namespace:GrapeCity.Windows.InputMan.Fields;assembly=GrapeCity.WPF.InputMan">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Themes/Generic/Common.xaml"/>
        <ResourceDictionary Source="/Themes/Generic/Base.xaml"/>
        <ResourceDictionary Source="/Themes/Generic/SideButton.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type im:GcNumber}" BasedOn="{StaticResource FieldsEditorControlStyle}" x:Key="GcNumber_StyleKey">
        <Style.Setters>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type im:GcNumber}">
                        <Border Background="{TemplateBinding Panel.Background}"
                                    BorderBrush="{TemplateBinding Control.BorderBrush}"
                                    BorderThickness="{TemplateBinding Control.BorderThickness}"
                                    FlowDirection="{TemplateBinding FrameworkElement.FlowDirection}"
                                    Name="Bd"
                                    SnapsToDevicePixels="True">
                          <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                              <VisualState x:Name="Normal"/>
                              <VisualState x:Name="Disabled">
                                <Storyboard>
                                  <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DisabledBackground">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                      <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Visible</Visibility>
                                      </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                  </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                              </VisualState>
                            </VisualStateGroup>
                                <VisualStateGroup x:Name="SpinButtonStates">
                                    <VisualState x:Name="SpinButtonVisible"/>
                                    <VisualState x:Name="SpinButtonCollapsed">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="SpinButtonPanel">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Collapsed</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="DropDownButtonStates">
                                    <VisualState x:Name="DropDownButtonVisible">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DropDownButton">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="DropDownButtonCollapsed"/>
                                </VisualStateGroup>
                          </VisualStateManager.VisualStateGroups>

                            <Grid Name="Placement"
                                  SnapsToDevicePixels="true">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Rectangle Grid.ColumnSpan="3" x:Name="DisabledBackground" IsHitTestVisible="False" Fill="{TemplateBinding DisabledBackground}" StrokeThickness="0" Visibility="Collapsed"/>

                                <imp:DropDownWindow x:Name="PART_Popup"
                                       Style="{TemplateBinding DropDownWindowStyle}"
                                       TargetElementValue="{Binding Path=Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
                                       Grid.ColumnSpan="2"
                                       IsOpen="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}">
                                    <Border x:Name="PART_ResizeHolder" Background="White" BorderThickness="1" BorderBrush="Black">
                                        <Grid>
                                            <Grid.RowDefinitions>
                                                <RowDefinition />
                                                <RowDefinition Height="auto"/>
                                            </Grid.RowDefinitions>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition/>
                                                <ColumnDefinition/>
                                                <ColumnDefinition/>
                                            </Grid.ColumnDefinitions>
                                            <im:GcDropDownCalculator Grid.ColumnSpan="3" x:Name="PART_DropDownChild" 
                                                         BorderThickness="0" BorderBrush="{x:Null}" FocusVisualStyle="{x:Null}"
                                                         Value="{Binding ElementName=PART_Popup, Path=DropDownValue, Mode=TwoWay}">
                                                <im:GcDropDownCalculator.InputBindings>
                                                    <KeyBinding Command="ApplicationCommands.NotACommand" Key="Escape"/>
                                                    <KeyBinding Command="imp:DropDownWindow.SubmitCommand" Key="Enter"/>
                                                </im:GcDropDownCalculator.InputBindings>
                                            </im:GcDropDownCalculator>
                                            <Button Grid.Row="1" Margin="0,0,0,7" Grid.Column="1" Focusable="False" IsDefault="True" Content="OK"
                                                    CommandTarget="{Binding ElementName=PART_DropDownChild}"
                                                    Command="{x:Static imp:DropDownWindow.SubmitCommand}"/>
                                        </Grid>
                                    </Border>
                                </imp:DropDownWindow>
                                <im:FieldsPresenter x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"/>
                                <Grid Grid.Column="1" x:Name="SpinButtonPanel" SnapsToDevicePixels="True" Margin="0,1,1,1">
                                    <Grid.RowDefinitions>
                                        <RowDefinition/>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>
                                    <imp:SpinButton Command="im:FieldsEditingCommands.SpinUp" Content="{StaticResource UpArrowGeometry}"/>
                                    <imp:SpinButton Command="im:FieldsEditingCommands.SpinDown" Content="{StaticResource DownArrowGeometry}" Grid.Row="1"/>
                                </Grid>
                                <imp:DropDownButton x:Name="DropDownButton" Grid.Column="2" Visibility="Collapsed"
                                              IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"/>
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="ControlValidatorSet" Value=""/>
        </Style.Setters>
    </Style>
    <Style TargetType="im:GcNumber" BasedOn="{StaticResource GcNumber_StyleKey}"/>
    <Style TargetType="{x:Type if:NumberSignPrefixField}" BasedOn="{StaticResource FieldStyle}"/>
    <Style TargetType="{x:Type if:NumberIntegerPartField}" BasedOn="{StaticResource FieldStyle}"/>
    <Style TargetType="{x:Type if:NumberDecimalSeparatorField}" BasedOn="{StaticResource FieldStyle}"/>
    <Style TargetType="{x:Type if:NumberDecimalPartField}" BasedOn="{StaticResource FieldStyle}"/>
    <Style TargetType="{x:Type if:NumberSignSuffixField}" BasedOn="{StaticResource FieldStyle}"/>
    <Style TargetType="{x:Type if:NumberDisplayField}" BasedOn="{StaticResource DisplayFieldStyle}"/>
</ResourceDictionary>