彩色动画内容presenter [英] Color Animation ContentPresenter

查看:227
本文介绍了彩色动画内容presenter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能创建一个动画,或自定义内容presenter(NormalTextDay)颜色,出现在我的XAML这个错误:

System.Windows.Media.Animation.ColorAnimation动画对象不能用于动画属性前景这是因为不兼容的类型'System.Windows.Media.Brush

 <风格X:键=CalendarDayButtonStyle的TargetType ={X:类型CalendarDayButton}>
    < setter属性=了minWidthVALUE =5/>
    < setter属性=了minHeightVALUE =5/>
    < setter属性=字号VALUE =10/>
    < setter属性=Horizo​​ntalContentAlignmentVALUE =中心/>
    < setter属性=VerticalContentAlignmentVALUE =中心/>
    < setter属性=模板>
        < Setter.Value>
            <的ControlTemplate的TargetType ={X:类型CalendarDayButton}>
                <网格和GT;
                    < VisualStateManager.VisualStateGroups>
                        < VisualStateGroup X:NAME =CommonStates>
                            < VisualStateGroup.Transitions>
                                &所述; VisualTransition GeneratedDuration =0:0:0.1/>
                            < /VisualStateGroup.Transitions>
                            <的VisualState X:名称=正常/>
                            <的VisualState X:NAME =鼠标悬停>
                                <情节提要>
                                    < D​​oubleAnimation是持续时间=0=0.5Storyboard.TargetProperty =透明度Storyboard.TargetName =HighlightBackground/>
                                < /故事板>
                            < /&的VisualState GT;
                            <的VisualState X:NAME =pressed>
                                <情节提要>
                                    < D​​oubleAnimation是持续时间=0=0.5Storyboard.TargetProperty =透明度Storyboard.TargetName =HighlightBackground/>
                                < /故事板>
                            < /&的VisualState GT;
                            <的VisualState X:名称=已禁用>
                                <! - <情节提要>
                                    &所述; DoubleAnimation是持续时间=0要=0Storyboard.TargetProperty =透明度Storyboard.TargetName =HighlightBackground/>
                                    < D​​oubleAnimation是持续时间=0= Storyboard.TargetProperty =透明度Storyboard.TargetName =NormalText/&GT35。
                                &所述; /故事板&GT - →;
                            < /&的VisualState GT;
                        < / VisualStateGroup>
                        < VisualStateGroup X:NAME =SelectionStates>
                            < VisualStateGroup.Transitions>
                                &所述; VisualTransition GeneratedDuration =0/>
                            < /VisualStateGroup.Transitions>
                            <的VisualState X:NAME =未选定/>
                            <的VisualState X:NAME =选择>
                                <情节提要>
                                    < D​​oubleAnimation是持续时间=0= Storyboard.TargetProperty =透明度Storyboard.TargetName =SelectedBackground/&GT75。
                                < /故事板>
                            < /&的VisualState GT;
                        < / VisualStateGroup>
                        < VisualStateGroup X:NAME =CalendarButtonFocusStates>
                            < VisualStateGroup.Transitions>
                                &所述; VisualTransition GeneratedDuration =0/>
                            < /VisualStateGroup.Transitions>
                            <的VisualState X:NAME =CalendarButtonFocused>
                                <情节提要>
                                    < ObjectAnimationUsingKeyFrames持续时间=0Storyboard.TargetProperty =可见性Storyboard.TargetName =DayButtonFocusVisual>
                                        &所述; DiscreteObjectKeyFrame KeyTime =0>
                                            < D​​iscreteObjectKeyFrame.Value>
                                                <能见度和GT;可见的LT; /能见度和GT;
                                            < /DiscreteObjectKeyFrame.Value>
                                        < / DiscreteObjectKeyFrame>
                                    < / ObjectAnimationUsingKeyFrames>
                                < /故事板>
                            < /&的VisualState GT;
                            <的VisualState X:NAME =CalendarButtonUnfocused>
                                <情节提要>
                                    < ObjectAnimationUsingKeyFrames持续时间=0Storyboard.TargetProperty =可见性Storyboard.TargetName =DayButtonFocusVisual>
                                        &所述; DiscreteObjectKeyFrame KeyTime =0>
                                            < D​​iscreteObjectKeyFrame.Value>
                                                <能见度和GT;倒塌< /能见度和GT;
                                            < /DiscreteObjectKeyFrame.Value>
                                        < / DiscreteObjectKeyFrame>
                                    < / ObjectAnimationUsingKeyFrames>
                                < /故事板>
                            < /&的VisualState GT;
                        < / VisualStateGroup>
                        < VisualStateGroup X:NAME =ActiveStates>
                            < VisualStateGroup.Transitions>
                                &所述; VisualTransition GeneratedDuration =0/>
                            < /VisualStateGroup.Transitions>
                            <的VisualState X:名称=活动/>
                            <的VisualState X:名称=无效>
                                <情节提要>
                                    &所述; DoubleAnimation是持续时间=0要=0Storyboard.TargetProperty =透明度Storyboard.TargetName =NormalTextDay/>
                                    &所述; DoubleAnimation是持续时间=0要=0Storyboard.TargetProperty =透明度Storyboard.TargetName =GridValues​​/>
                                    &所述;! - &下; C​​olorAnimationUsingKeyFrames Storyboard.TargetProperty =(TextBlock.Foreground)(SolidColorBrush.Color)。Storyboard.TargetName =NormalTextDay>
                                        &所述; EasingColorKeyFrame KeyTime =0值=#FFA71616/>
                                    &所述; / ColorAnimationUsingKeyFrames&GT - →;                                    &所述;! - &下; C​​olorAnimation持续时间=0要=#FF777777Storyboard.TargetProperty =(TextBlock.Foreground)(SolidColorBrush.Color)。Storyboard.TargetName =NormalTextDay/&GT - →;
                                < /故事板>                            < /&的VisualState GT;
                        < / VisualStateGroup>
                        < VisualStateGroup X:NAME =DayStates>
                            < VisualStateGroup.Transitions>
                                &所述; VisualTransition GeneratedDuration =0/>
                            < /VisualStateGroup.Transitions>
                            <的VisualState X:NAME =RegularDay/>
                            <的VisualState X:名称=今天>
                                <情节提要>
                                    &所述; DoubleAnimation是持续时间=0要=1Storyboard.TargetProperty =透明度Storyboard.TargetName =TodayBackground/>
                                    &所述; ColorAnimation持续时间=0要=#FFFFFFFFStoryboard.TargetProperty =。(TextBlock.Foreground)(SolidColorBrush.Color)Storyboard.TargetName =NormalTextDay/>
                                < /故事板>
                            < /&的VisualState GT;
                        < / VisualStateGroup>
                        < VisualStateGroup X:NAME =BlackoutDayStates>
                            < VisualStateGroup.Transitions>
                                &所述; VisualTransition GeneratedDuration =0/>
                            < /VisualStateGroup.Transitions>
                            <的VisualState X:NAME =NormalDay/>
                            <的VisualState X:NAME =BlackoutDay>
                                <情节提要>
                                    < D​​oubleAnimation是持续时间=0= Storyboard.TargetProperty =透明度Storyboard.TargetName =停电/&GT2。
                                < /故事板>
                            < /&的VisualState GT;
                        < / VisualStateGroup>
                    < /VisualStateManager.VisualStateGroups>
                    < Grid.RowDefinitions>
                        < RowDefinition高度=自动/>
                        < RowDefinition高度=*/>
                    < /Grid.RowDefinitions>
                    &所述;矩形X:名称=TodayBackground填充=#FFAAAAAA透明度=0半径=1半径=1Grid.RowSpan =2/>
                    &所述;矩形X:名称=SelectedBackground填充=#FFBADDE9透明度=0半径=1半径=1Grid.RowSpan =2/>
                    < BORDER BorderBrush ={TemplateBinding BorderBrush}了borderThickness ={TemplateBinding了borderThickness}Grid.RowSpan =2背景={TemplateBinding背景}/>
                    &所述;矩形X:名称=HighlightBackground填充=#FFBADDE9透明度=0半径=1半径=1Grid.RowSpan =2/>
                    <内容presenter X:名称=NormalTextDayTextBlock.Foreground =#FF333333的Horizo​​ntalAlignment ={TemplateBinding Horizo​​ntalContentAlignment}VerticalAlignment ={TemplateBinding VerticalContentAlignment}Grid.Row =0>
                    < /内容presenter>                        <路径X:NAME =停电数据=M8.1772461,11.029181 L10.433105,11.029181 L11.700684,12.801641 L12.973633,11.029181 L15.191895,11.029181 L12.844727,13.999395 L15.21875,17.060919 L12。 962891,17.060919 L11.673828,15.256231 L10.352539,17.060919 L8.1396484,17.060919 L10.519043,14.042364 Z补=#FF000000的Horizo​​ntalAlignment =拉伸保证金=3不透明度=0RenderTransformOrigin =0.5 ,0.5拉伸=填充VerticalAlignment =拉伸Grid.RowSpan =2/>
                    <矩形X:NAME =DayButtonFocusVisualIsHitTestVisible =假半径=1半径=1行程=#FF45D6FA能见度=坍塌Grid.RowSpan =2/>
                    &所述;数据网格保证金=0,0,0,0×:名称=GridValues​​Grid.Row =1>
                        < D​​ataGrid.Columns>
                            &所述; DataGridTemplateColumn部首=Período宽度=*了maxWidth =200/>
                            < D​​ataGridTemplateColumn标题=Nº最大。 WIDTH =自动/>
                        < /DataGrid.Columns>
                    < / DataGrid的>
                < /网格和GT;
            < /控件模板>
        < /Setter.Value>
    < /二传手>
< /样式和GT;


解决方案

不太清楚......但你可能需要改变这样的:

  Storyboard.TargetProperty =(TextBlock.Foreground)。(SolidColorBrush.Color)

这样:

  Storyboard.TargetProperty =(TextBlock.Foreground)。颜色

在本语法前景和的SolidColorBrush是同一个对象,你似乎是重复的。

I can't create an animation, or customize a color in ContentPresenter (NormalTextDay), this error appears in my XAML:

'System.Windows.Media.Animation.ColorAnimation' animation object can not be used to animate property 'Foreground' it is because of incompatible type 'System.Windows.Media.Brush

  <Style x:Key="CalendarDayButtonStyle" TargetType="{x:Type CalendarDayButton}">
    <Setter Property="MinWidth" Value="5"/>
    <Setter Property="MinHeight" Value="5"/>
    <Setter Property="FontSize" Value="10"/>
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type CalendarDayButton}">
                <Grid>
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0:0:0.1"/>
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="Normal"/>
                            <VisualState x:Name="MouseOver">
                                <Storyboard>
                                    <DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightBackground"/>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Pressed">
                                <Storyboard>
                                    <DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightBackground"/>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Disabled">
                                <!--<Storyboard>
                                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightBackground"/>
                                    <DoubleAnimation Duration="0" To=".35" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="NormalText"/>
                                </Storyboard>-->
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="SelectionStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0"/>
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="Unselected"/>
                            <VisualState x:Name="Selected">
                                <Storyboard>
                                    <DoubleAnimation Duration="0" To=".75" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="SelectedBackground"/>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="CalendarButtonFocusStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0"/>
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="CalendarButtonFocused">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DayButtonFocusVisual">
                                        <DiscreteObjectKeyFrame KeyTime="0">
                                            <DiscreteObjectKeyFrame.Value>
                                                <Visibility>Visible</Visibility>
                                            </DiscreteObjectKeyFrame.Value>
                                        </DiscreteObjectKeyFrame>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="CalendarButtonUnfocused">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DayButtonFocusVisual">
                                        <DiscreteObjectKeyFrame KeyTime="0">
                                            <DiscreteObjectKeyFrame.Value>
                                                <Visibility>Collapsed</Visibility>
                                            </DiscreteObjectKeyFrame.Value>
                                        </DiscreteObjectKeyFrame>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="ActiveStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0"/>
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="Active"/>
                            <VisualState x:Name="Inactive">
                                <Storyboard>
                                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="NormalTextDay"/>
                                    <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="GridValues"/>
                                    <!--<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="NormalTextDay">
                                        <EasingColorKeyFrame KeyTime="0" Value="#FFA71616"/>
                                    </ColorAnimationUsingKeyFrames>-->

                                    <!--<ColorAnimation Duration="0" To="#FF777777" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="NormalTextDay"/>-->
                                </Storyboard>

                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="DayStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0"/>
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="RegularDay"/>
                            <VisualState x:Name="Today">
                                <Storyboard>
                                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="TodayBackground"/>
                                    <ColorAnimation Duration="0" To="#FFFFFFFF" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="NormalTextDay"/>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="BlackoutDayStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition GeneratedDuration="0"/>
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="NormalDay"/>
                            <VisualState x:Name="BlackoutDay">
                                <Storyboard>
                                    <DoubleAnimation Duration="0" To=".2" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Blackout"/>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Rectangle x:Name="TodayBackground" Fill="#FFAAAAAA" Opacity="0" RadiusY="1" RadiusX="1" Grid.RowSpan="2"/>
                    <Rectangle x:Name="SelectedBackground" Fill="#FFBADDE9" Opacity="0" RadiusY="1" RadiusX="1" Grid.RowSpan="2"/>
                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.RowSpan="2" Background="{TemplateBinding Background}"/>
                    <Rectangle x:Name="HighlightBackground" Fill="#FFBADDE9" Opacity="0" RadiusY="1" RadiusX="1" Grid.RowSpan="2"/>
                    <ContentPresenter x:Name="NormalTextDay" TextBlock.Foreground="#FF333333" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Grid.Row="0">
                    </ContentPresenter>

                        <Path x:Name="Blackout" Data="M8.1772461,11.029181 L10.433105,11.029181 L11.700684,12.801641 L12.973633,11.029181 L15.191895,11.029181 L12.844727,13.999395 L15.21875,17.060919 L12.962891,17.060919 L11.673828,15.256231 L10.352539,17.060919 L8.1396484,17.060919 L10.519043,14.042364 z" Fill="#FF000000" HorizontalAlignment="Stretch" Margin="3" Opacity="0" RenderTransformOrigin="0.5,0.5" Stretch="Fill" VerticalAlignment="Stretch" Grid.RowSpan="2"/>
                    <Rectangle x:Name="DayButtonFocusVisual" IsHitTestVisible="false" RadiusY="1" RadiusX="1" Stroke="#FF45D6FA" Visibility="Collapsed" Grid.RowSpan="2"/>
                    <DataGrid Margin="0,0,0,0" x:Name="GridValues" Grid.Row="1">
                        <DataGrid.Columns>
                            <DataGridTemplateColumn Header="Período" Width="*" MaxWidth="200"/>
                            <DataGridTemplateColumn Header="Nº Max." Width="Auto" />
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

解决方案

Not quite sure... but you might need to change this:

Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"

to this:

Storyboard.TargetProperty="(TextBlock.Foreground).Color"

as in this syntax "Foreground" and "SolidColorBrush" are the same object you seem to be duplicating it.

这篇关于彩色动画内容presenter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆