2012-02-25 18 views
1

私は問題に直接行きます。私のコードでは、楕円の配列がある、すなわち
Ellipse[] players = new Ellipse[11];
、その後、私はWPFで複数のオブジェクトにアニメーションを割り当てる

sboard.Children.Add(anim); 
sboard.Children.Add(anim2); 
Storyboard.SetTargetName(anim, players[player - 1].Name); 
Storyboard.SetTargetName(anim2, players[player - 1].Name); 
Storyboard.SetTargetProperty(anim, new PropertyPath(Canvas.LeftProperty)); 
Storyboard.SetTargetProperty(anim2, new PropertyPath(Canvas.TopProperty)); 

を使用して、キャンバスにこれらの楕円をアニメーション化するDoubleAnimationWithKeyFramesを使用しかし、私はこれらの省略記号でいくつかのテキストブロックを移動したいです。これらのTextBlockにどのように同じアニメーションとアニメーション2を割り当てることができますか?

答えて

1

EllipseとTextBlockをコンテナ(グリッド、スタックパネル、キャンバスなど)に配置するか、UserControlを作成し、楕円の代わりにアニメーションします。

例:

<UserControl 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
mc:Ignorable="d" 
x:Class="WpfApplication4.UserControl1" 
x:Name="UserControl"> 

<StackPanel x:Name="LayoutRoot"> 
    <Ellipse Fill="#FFF4F4F5" Height="100" Stroke="Black" Width="100"/> 
    <TextBlock TextWrapping="Wrap" Text="Some Text Here" FontSize="32" HorizontalAlignment="Center"/> 
</StackPanel></UserControl> 
関連する問題