none
请问storybord的targetproperty该怎样设置? RRS feed

  • 问题

  • 因为silverlight3增加了3d支持,所以我想创建一个动画,改变Image的RotationX属性,从0到180的一个动画,然后定义storybord的时候填写targetproperty不知道该怎么填,好像RotationX属于依赖属性的,各位高手告诉我一下,谢谢


    stoneluo
    2009年5月4日 10:23

答案

  • <UserControl
    	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    	x:Class="SilverlightApplication2.MainControl"
    	Width="640" Height="480">
    	<UserControl.Resources>
    		<Storyboard x:Name="mystorybord">
    			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="myimage" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)">
    				<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
    				<EasingDoubleKeyFrame KeyTime="00:00:05" Value="179"/>
    			</DoubleAnimationUsingKeyFrames>
    		</Storyboard>
    	</UserControl.Resources>
    
    	<Grid x:Name="LayoutRoot" Background="White">
    		<Rectangle x:Name="myimage" Fill="#FFE94545" Stroke="#FF000000" Height="48" HorizontalAlignment="Left" Margin="145,192,0,0" VerticalAlignment="Top" Width="147" MouseLeftButtonDown="myimage_MouseLeftButtonDown">
    			<Rectangle.Projection>
    				<PlaneProjection/>
    			</Rectangle.Projection>
    		</Rectangle>
    	</Grid>
    </UserControl>
    cs文件:
    namespace SilverlightApplication2
    {
    	public partial class MainControl : UserControl
    	{
    		public MainControl()
    		{
    			// Required to initialize variables
    			InitializeComponent();
    		}
    
            private void myimage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
            {
                mystorybord.Begin();
            }
    	}
    }
    2009年5月5日 2:35
    版主

全部回复

  • PlaneProjection.RotationXProperty
    2009年5月4日 12:00
    版主
  • PlaneProjection.RotationXProperty


    我这样写对吗?
    xaml文件:
    <UserControl x:Class="SilverlightApplication2.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Width="400" Height="300">
        <Grid x:Name="LayoutRoot" Background="White">
            <Grid.Resources>
                <Storyboard x:Name="mystorybord">
                    <DoubleAnimation Storyboard.TargetName="myimage" Storyboard.TargetProperty="PlaneProjection.RotationXProperty" Duration="0:0:5" From="0" To="180"/>
                </Storyboard>
            </Grid.Resources>
                <Image x:Name="myimage" Source="test.jpg" Width="600" Height="500" MouseLeftButtonDown="myimage_MouseLeftButtonDown"/>
                          </Grid>
    </UserControl>
    cs文件:
    namespace SilverlightApplication2
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
            }

         private void myimage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
            {
                mystorybord.Begin();
            }
        }
    }
    但是这样我把鼠标点击以后没反应啊?


    stoneluo
    2009年5月4日 15:16
  • <UserControl
    	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    	x:Class="SilverlightApplication2.MainControl"
    	Width="640" Height="480">
    	<UserControl.Resources>
    		<Storyboard x:Name="mystorybord">
    			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="myimage" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)">
    				<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
    				<EasingDoubleKeyFrame KeyTime="00:00:05" Value="179"/>
    			</DoubleAnimationUsingKeyFrames>
    		</Storyboard>
    	</UserControl.Resources>
    
    	<Grid x:Name="LayoutRoot" Background="White">
    		<Rectangle x:Name="myimage" Fill="#FFE94545" Stroke="#FF000000" Height="48" HorizontalAlignment="Left" Margin="145,192,0,0" VerticalAlignment="Top" Width="147" MouseLeftButtonDown="myimage_MouseLeftButtonDown">
    			<Rectangle.Projection>
    				<PlaneProjection/>
    			</Rectangle.Projection>
    		</Rectangle>
    	</Grid>
    </UserControl>
    cs文件:
    namespace SilverlightApplication2
    {
    	public partial class MainControl : UserControl
    	{
    		public MainControl()
    		{
    			// Required to initialize variables
    			InitializeComponent();
    		}
    
            private void myimage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
            {
                mystorybord.Begin();
            }
    	}
    }
    2009年5月5日 2:35
    版主
  • <Rectangle.Projection>
         <PlaneProjection/>
    </Rectangle.Projection>

    xaml中添加Projection属性后,才能在StoryBoard里进行控制
    2009年5月5日 2:37
    版主
  • <Rectangle.Projection>
         <PlaneProjection/>
    </Rectangle.Projection>

    xaml中添加Projection属性后,才能在StoryBoard里进行控制
    谢谢八爪熊的热情回复,看了我基础没打捞啊,呵呵
    stoneluo
    2009年5月5日 17:12