首页 新闻 会员 周边 捐助

在Silverlight样式中,不用Storyboard.TargetName,能改变目标控件属性吗?

0
悬赏园豆:10 [已关闭问题] 关闭于 2014-06-03 14:12

在主题中的样式中,设置动画来改变目标的属性(要修改RepeatButton的Foreground属性)

 1   <Style TargetType="RepeatButton">
 2         <Setter Property="Foreground" Value="Black"/>
 3         <Setter Property="BorderThickness" Value="0"/>
 4         <Setter Property="Background" Value="#FFB8D9F8"/>
 5         <Setter Property="FontSize" Value="14"/>
 6         <Setter Property="FontFamily" Value="KaiTi"/>
 7         <Setter Property="Template">
 8             <Setter.Value>
 9                 <ControlTemplate TargetType="RepeatButton">
10                     <Grid>
11                         <VisualStateManager.VisualStateGroups>
12                             <VisualStateGroup x:Name="CommonStates">
13                                 <VisualState x:Name="Normal">
14                                     <Storyboard>
15                                     </Storyboard>
16                                 </VisualState>
17                                 <VisualState x:Name="MouseOver">
18                                     <Storyboard>
19                                         <DoubleAnimation Duration="0" Storyboard.TargetName="py1" Storyboard.TargetProperty="Opacity" To="0.2"/>
20                                     </Storyboard>
21                                 </VisualState>
22                                 <VisualState x:Name="Pressed">
23                                 </VisualState>
24                                 <VisualState x:Name="Disabled">
25                                 </VisualState>
26                             </VisualStateGroup>
27                         </VisualStateManager.VisualStateGroups>
28                         <Polygon x:Name="py1" Points="0 0,115 0,115 33,0 33"  Fill="White" Stroke="Black" StrokeThickness="1"  FillRule="EvenOdd" Opacity="0"/>
29                         <Line X1="115" Y1="0" X2="115" Y2="33" StrokeDashArray="2"  Stroke="#FF535050" StrokeThickness="1"/>
30                         <ContentPresenter  HorizontalAlignment="Center" VerticalAlignment="Center"/>
31                     </Grid>
32                 </ControlTemplate>
33             </Setter.Value>
34         </Setter>
35     </Style>

 

金鸡岭的主页 金鸡岭 | 初学一级 | 园豆:9
提问于:2014-05-12 11:28
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册