首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > CAD教程 >

动画片对象不能用于动画属性“BorderThickness”,因为它是不兼容的类型

2013-03-20 
动画对象不能用于动画属性“BorderThickness”,因为它是不兼容的类型“System.Windows.Media.Animation.Doubl

动画对象不能用于动画属性“BorderThickness”,因为它是不兼容的类型


“System.Windows.Media.Animation.DoubleAnimation”动画对象不能用于动画属性“BorderThickness”,因为它是不兼容的类型“System.Windows.Thickness”。

遇到一个奇怪的问题:为一个自定义的控件(继承自Button)设置ControlTemplate,如果设置
ControlTemplate的TargetType="{x:Type ButtonBase}",下面的动画就会抛出异常,如果不
设置TargetType="{x:Type ButtonBase}",ControlTemplate的设置就无效。求众位指点。

<Style TargetType="{x:Type local:ImageButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ButtonBase}">
                    <Border x:Name="border" BorderBrush="Blue" BorderThickness="0">
                        <ContentPresenter/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <EventTrigger RoutedEvent="MouseEnter">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation To="0.5" Duration="0:0:1" AutoReverse="False"
                                            Storyboard.TargetName="border"
                                            Storyboard.TargetProperty="(Border.BorderThickness)"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="MouseLeave">
                            <BeginStoryboard>


                                <Storyboard>
                                    <DoubleAnimation To="0" Duration="0:0:1" AutoReverse="False"
                                            Storyboard.TargetName="border"
                                            Storyboard.TargetProperty="(Border.BorderThickness)"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


[解决办法]
DoubleAnimation 真的可以用于   BorderThickness 吗?

BorderThickness 是 Thickness 结构体。。

热点排行