silverlight 怎么设置控件在Grid中的位置,用Storyboard实现移动怎么设置SetTargetProperty
1个回答
展开全部
用grid不太好吧! 好像实现不了! 要用canvas 然后动画控制canvas。left 和canvans。top 属性就可以了! 不是要实现字幕滚动的效果吧? 我写个例子
<UserControl.Resources>
<Storyboard x:Name="animation" Storyboard.TargetProperty="(Canvas.Top)" RepeatBehavior="Forever" >
<DoubleAnimation x:Name="ani1" Storyboard.TargetName="stacktop" From="50" To="-1050" />
<DoubleAnimation x:Name="ani2" Storyboard.TargetName="stackdown" From="1100" To="50" />
</Storyboard>
</UserControl.Resources>
<Canvas x:Name="a" Background="White" MouseEnter="a_MouseEnter" MouseLeave="a_MouseLeave" >
<Canvas.Clip>
<RectangleGeometry RadiusX="0" RadiusY="0" Rect="180,50, 720,450" >
</RectangleGeometry>
</Canvas.Clip>
<StackPanel Orientation="Vertical" Name="stacktop" Canvas.Left="200" Canvas.Top="50" Width="720" Height="1100" Background="#00111111" ></StackPanel>
<StackPanel Orientation="Vertical" Name="stackdown" Canvas.Left="200" Canvas.Top="1100" Width="720" Height="1100" Background="#00111111" ></StackPanel>
</Canvas>
<UserControl.Resources>
<Storyboard x:Name="animation" Storyboard.TargetProperty="(Canvas.Top)" RepeatBehavior="Forever" >
<DoubleAnimation x:Name="ani1" Storyboard.TargetName="stacktop" From="50" To="-1050" />
<DoubleAnimation x:Name="ani2" Storyboard.TargetName="stackdown" From="1100" To="50" />
</Storyboard>
</UserControl.Resources>
<Canvas x:Name="a" Background="White" MouseEnter="a_MouseEnter" MouseLeave="a_MouseLeave" >
<Canvas.Clip>
<RectangleGeometry RadiusX="0" RadiusY="0" Rect="180,50, 720,450" >
</RectangleGeometry>
</Canvas.Clip>
<StackPanel Orientation="Vertical" Name="stacktop" Canvas.Left="200" Canvas.Top="50" Width="720" Height="1100" Background="#00111111" ></StackPanel>
<StackPanel Orientation="Vertical" Name="stackdown" Canvas.Left="200" Canvas.Top="1100" Width="720" Height="1100" Background="#00111111" ></StackPanel>
</Canvas>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询