tags:

views:

294

answers:

1

Hi,

I'm struggling to get a PropertyPath to work - I've got a Transformation in the Window Resources that I'm trying to affect via a StoryBoard - also in Window Resources ...

Heres the property path i'm using ...

(Viewport2DVisual3D.Transform).(Transform3DGroup)[0].(RotateTransform3D).(RotateTransform3D.Rotation).(AxisAngleRotation3D.Angle)

EDIT: Thanks to Anurags suggestion I've got a bit further ... (Viewport2DVisual3D.Transform).(Transform3DGroup.Children)[0].(RotateTransform3D.Rotation).(AxisAngleRotation3D.Angle)

but now it errors with "Rotation property does not point to a DependencyProperty"

Can anyone please put me back on track?

Heres the code in full ...

<Window
x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
    <Window.Resources>

        <Transform3DGroup x:Key="WorldTranslation">
            <RotateTransform3D>
                <RotateTransform3D.Rotation>
                    <AxisAngleRotation3D Axis="0,1,0" Angle="0" />
                </RotateTransform3D.Rotation>
            </RotateTransform3D>
        </Transform3DGroup>

          <Storyboard x:Key="MyStoryboard">
        <DoubleAnimation
       Storyboard.Target="{Binding TemplatedParent}"     
       Storyboard.TargetProperty="(Viewport2DVisual3D.Transform).(Transform3DGroup.Children)[0].(RotateTransform3D.Rotation).(AxisAngleRotation3D.Angle)"
       From="0.0" To="360" Duration="0:0:1" />
    </Storyboard>

        <MeshGeometry3D
            x:Key="squareMeshFrontLeft"
            Positions="-1,-1,1 1,-1,1 1,1,1 -1,1,1"
            TriangleIndices="0 1 2 0 2 3"
            TextureCoordinates="0,1 1,1 1,0 0,0" />

        <DiffuseMaterial x:Key="visualHostMaterial" Brush="White" Viewport2DVisual3D.IsVisualHostMaterial="True" />
    </Window.Resources>

    <Viewport3D>
        <Viewport3D.Camera>
            <PerspectiveCamera Position="0,0,10" LookDirection="0,0,-1" />
        </Viewport3D.Camera>
        <Viewport2DVisual3D Material="{StaticResource visualHostMaterial}" Geometry="{StaticResource squareMeshFrontLeft}" >
            <Viewport2DVisual3D.Transform>
                <StaticResource ResourceKey="WorldTranslation" />
            </Viewport2DVisual3D.Transform>
            <StackPanel Background="Blue" Width="80" Height="80">
                <Button Height="30" Margin="20">
                    <Button.Content>Blah</Button.Content>
                    <Button.Triggers>
                        <EventTrigger RoutedEvent="Button.Click">
                            <EventTrigger.Actions>
                                <BeginStoryboard Storyboard="{StaticResource MyStoryboard}" >
                                </BeginStoryboard>
                            </EventTrigger.Actions>
                        </EventTrigger>
                    </Button.Triggers>
                </Button>
            </StackPanel>
        </Viewport2DVisual3D>
                <ModelVisual3D>
            <ModelVisual3D.Content>
                <AmbientLight Color="White" />
            </ModelVisual3D.Content>
        </ModelVisual3D>
    </Viewport3D>
</Window>
+1  A: 

First of all, instead of DoubleAnimation, use 3D KeyFrame Animation.

and correct your StoryBoard.TargetProperty's syntax using (Transform3DGroup.Children) instead of

check this also: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/78170274-a585-4cd6-85ed-edfd655d34ab

viky
Hi, thanks for your assistance, i'll definately have a look at using KeyFrames instead of my double animation - but with regards to the property path - I tried adding the .Children as you suggested, I also removed the first RotateTransform3D as I realised it wasnt needed ... heres what I've got now ... (Viewport2DVisual3D.Transform).(Transform3DGroup.Children)[0].(RotateTransform3D.Rotation).(AxisAngleRotation3D.Angle) But now it errors with 'Rotation' property does not point to a dependency object. Do you have any ideas please?
Andy Clarke
Same Error I was also getting when using Double Animation, Thats why I said to use 3D KeyFrame Animation instead of DoubleAnimation. Couldn't get time to check it with 3D KeyFrame Animation, you try!!
viky