MESCIUS InputMan for WPF 3.0J > InputMan for WPF の使い方 > テーマテンプレートを使用する > テーマテンプレートのカスタマイズ > CalendarButtons.xaml |
CalendarButtons.xaml では、ドロップダウンカレンダーコントロール上のボタンの外観を定義します。
CalendarButtons.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"> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Themes/Generic/Common.xaml"/> <ResourceDictionary Source="/Themes/Generic/Calendar.xaml"/> </ResourceDictionary.MergedDictionaries> <Style TargetType="imp:CalendarHeaderButton" x:Key="CalendarHeaderButton_StyleKey"> <Setter Property="Foreground" Value="{StaticResource HeaderForegroundBrushKey}"/> <Setter Property="Background" Value="{StaticResource HeaderBackgroundBrushKey}"/> <Setter Property="Focusable" Value="false"/> <Setter Property="ClickMode" Value="Press"/> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="Cursor" Value="Hand"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="imp:CalendarHeaderButton"> <Grid Background="{TemplateBinding Background}"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal"/> <VisualState x:Name="MouseOver"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="buttonContent" Storyboard.TargetProperty="(TextElement.Foreground)" Duration="0" > <DiscreteObjectKeyFrame KeyTime="0"> <DiscreteObjectKeyFrame.Value> <SolidColorBrush Color="#FF73A9D8"/> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="Disabled"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="buttonContent" Storyboard.TargetProperty="(TextElement.Foreground)" Duration="0" > <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource GcCalendar_DisabledForegroundBrush}"/> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <ContentPresenter Margin="0,5" x:Name="buttonContent" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"> </ContentPresenter> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style TargetType="imp:CalendarHeaderButton" BasedOn="{StaticResource CalendarHeaderButton_StyleKey}"/> <SolidColorBrush x:Key="GcCalendar_ButtonFocusVisualBorderBrush" Color="#FF45D6FA"/> <DrawingBrush x:Key="BlackoutBrushKey" > <DrawingBrush.Drawing> <DrawingGroup > <GeometryDrawing Brush="#FF000000" Geometry="M8.1772461,11.029181L10.433105,11.029181 11.700684,12.801641 12.973633,11.029181 15.191895,11.029181 12.844727,13.999395 15.21875,17.060919 12.962891,17.060919 11.673828,15.256231 10.352539,17.060919 8.1396484,17.060919 10.519043,14.042364z"/> </DrawingGroup> </DrawingBrush.Drawing> </DrawingBrush> <DataTemplate DataType="{x:Type imp:DayInfo}"> <TextBlock x:Name="ContentText" Text="{Binding Text}" TextWrapping="NoWrap" HorizontalAlignment="Center" VerticalAlignment="Center"/> </DataTemplate> <Style TargetType="{x:Type imp:CalendarDayButton}" x:Key="CalendarDayButton_StyleKey"> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="SnapsToDevicePixels" Value="True"/> <Setter Property="Padding" Value="5,0" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type imp:CalendarDayButton}"> <Border x:Name="ButtonBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal"/> <VisualState x:Name="MouseOver"> <Storyboard> <DoubleAnimation Duration="0" Storyboard.TargetName="HoverBackground" Storyboard.TargetProperty="Opacity" To="0.2"/> </Storyboard> </VisualState> <VisualState x:Name="Pressed"> <Storyboard> <DoubleAnimation Duration="0" Storyboard.TargetName="HoverBackground" Storyboard.TargetProperty="Opacity" To="0.2"/> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="SelectionStates"> <VisualState x:Name="Unselected"/> <VisualState x:Name="Selected"> <Storyboard> <DoubleAnimation Duration="0" Storyboard.TargetName="SelectedBackground" Storyboard.TargetProperty="Opacity" To="0.3"/> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="ActiveStates"> <VisualState x:Name="Active"/> <VisualState x:Name="Inactive"> <Storyboard> <DoubleAnimation Duration="0" Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="Opacity" To="0.4"/> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="CalendarButtonFocusStates"> <VisualState x:Name="CalendarButtonUnfocused"/> <VisualState x:Name="CalendarButtonFocused"> <Storyboard> <DoubleAnimation Duration="0" Storyboard.TargetName="ButtonFocusVisual" Storyboard.TargetProperty="Opacity" To="1"/> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="DayStates"> <VisualState x:Name="RegularDay"/> <VisualState x:Name="Today"> <Storyboard> <DoubleAnimation Duration="0" Storyboard.TargetName="TodayBackground" Storyboard.TargetProperty="Opacity" To="1"/> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="BlackoutDayStates"> <VisualState x:Name="NormalDay"/> <VisualState x:Name="BlackoutDay"> <Storyboard> <DoubleAnimation Duration="0" Storyboard.TargetName="Blackout" Storyboard.TargetProperty="Opacity" To="0.2"/> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Grid > <Rectangle x:Name="TodayBackground" RadiusX="1" RadiusY="1" Opacity="0"/> <Rectangle x:Name="HoverBackground" RadiusX="1" RadiusY="1" Opacity="0" Fill="{Binding ElementName=SelectedBackground, Path=Fill, Mode=OneWay}" IsHitTestVisible="False"/> <Rectangle x:Name="SelectedBackground" RadiusX="1" RadiusY="1" Opacity="0"/> <ContentPresenter x:Name="PART_Content" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Margin="{TemplateBinding Padding}"> </ContentPresenter> <Rectangle x:Name="Blackout" Opacity="0" Margin="3" Fill="{StaticResource BlackoutBrushKey}" IsHitTestVisible="False" /> <Rectangle x:Name="ButtonFocusVisual" IsHitTestVisible="false" RadiusX="1" RadiusY="1" Opacity="0" Stroke="{StaticResource GcCalendar_ButtonFocusVisualBorderBrush}"/> </Grid> </Border> <ControlTemplate.Triggers> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Foreground" Value="{StaticResource GcCalendar_DisabledForegroundBrush}"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style TargetType="imp:CalendarDayButton" BasedOn="{StaticResource CalendarDayButton_StyleKey}"/> <DataTemplate DataType="{x:Type imp:CalendarInfo}"> <TextBlock x:Name="ContentText" Text="{Binding Text}" TextWrapping="NoWrap" HorizontalAlignment="Center" VerticalAlignment="Center"/> </DataTemplate> <Style TargetType="{x:Type imp:CalendarButton}" x:Key="CalendarButton_StyleKey"> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="SnapsToDevicePixels" Value="True"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type imp:CalendarButton}"> <Border x:Name="ButtonBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal"/> <VisualState x:Name="MouseOver"> <Storyboard> <DoubleAnimation Duration="0" Storyboard.TargetName="HoverBackground" Storyboard.TargetProperty="Opacity" To="0.2"/> </Storyboard> </VisualState> <VisualState x:Name="Pressed"> <Storyboard> <DoubleAnimation Duration="0" Storyboard.TargetName="HoverBackground" Storyboard.TargetProperty="Opacity" To="0.2"/> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="SelectionStates"> <VisualState x:Name="Unselected"/> <VisualState x:Name="Selected"> <Storyboard> <DoubleAnimation Duration="0" Storyboard.TargetName="SelectedBackground" Storyboard.TargetProperty="Opacity" To="0.3"/> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="ActiveStates"> <VisualState x:Name="Active"/> <VisualState x:Name="Inactive"> <Storyboard> <DoubleAnimation Duration="0" Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="Opacity" To="0.4"/> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="CalendarButtonFocusStates"> <VisualState x:Name="CalendarButtonUnfocused"/> <VisualState x:Name="CalendarButtonFocused"> <Storyboard> <DoubleAnimation Duration="0" Storyboard.TargetName="ButtonFocusVisual" Storyboard.TargetProperty="Opacity" To="1"/> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Grid> <Rectangle x:Name="HoverBackground" RadiusX="1" RadiusY="1" Opacity="0" Fill="{Binding ElementName=SelectedBackground, Path=Fill, Mode=OneWay}" IsHitTestVisible="False"/> <Rectangle x:Name="SelectedBackground" RadiusX="1" RadiusY="1" Opacity="0"/> <ContentPresenter x:Name="PART_Content" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Margin="{TemplateBinding Padding}"> </ContentPresenter> <Rectangle x:Name="ButtonFocusVisual" IsHitTestVisible="false" RadiusX="1" RadiusY="1" Stroke="{StaticResource GcCalendar_ButtonFocusVisualBorderBrush}" Opacity="0"/> </Grid> </Border> <ControlTemplate.Triggers> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Foreground" Value="{StaticResource GcCalendar_DisabledForegroundBrush}"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style TargetType="imp:CalendarButton" BasedOn="{StaticResource CalendarButton_StyleKey}"/> <DataTemplate DataType="{x:Type imp:WeekNumberInfo}"> <TextBlock x:Name="ContentText" Text="{Binding Text}" TextWrapping="NoWrap" HorizontalAlignment="Center" VerticalAlignment="Center"/> </DataTemplate> <Style TargetType="{x:Type imp:WeekNumber}" x:Key="WeekNumber_StyleKey"> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="Padding" Value="2,0"/> <Setter Property="Visibility" Value="Collapsed"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type imp:WeekNumber}"> <Border x:Name="ButtonBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <ContentPresenter x:Name="PART_Content" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}"/> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style TargetType="imp:WeekNumber" BasedOn="{StaticResource WeekNumber_StyleKey}"/> <DataTemplate DataType="{x:Type imp:WeekTitleInfo}"> <TextBlock x:Name="ContentText" Text="{Binding Text}" TextWrapping="NoWrap"/> </DataTemplate> <Style TargetType="imp:WeekTitle" x:Key="WeekTitle_StyleKey"> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="Padding" Value="0,6"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type imp:WeekTitle}"> <Border x:Name="ButtonBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <ContentPresenter x:Name="PART_Content" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}"/> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style TargetType="imp:WeekTitle" BasedOn="{StaticResource WeekTitle_StyleKey}"/> </ResourceDictionary>