我在努力獲得PropertyPath的工作 - 我試圖通過StoryBoard影響窗口資源中的轉換 - 也在窗口中資源...WPF PropertyPath問題 - 無法解析屬性路徑中的所有屬性引用
繼承人我使用的屬性路徑...
(Viewport2DVisual3D.Transform).(Transform3DGroup)[0].(RotateTransform3D).(RotateTransform3D.Rotation).(AxisAngleRotation3D.Angle)
編輯:感謝Anurags建議,我已經有了一個遠一點...... (Viewport2DVisual3D.Transform)( Transform3DGroup.Children)[0]。(RotateTransform3D.Rotation)。(AxisAngleRotation3D.Angle)
但現在它錯誤「旋轉屬性不指向一個DependencyProperty」
任何人都可以請讓我回到正軌?
繼承人的代碼完全...
<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>
您好,感謝您的幫助,我會肯定看看使用關鍵幀,而不是我的雙動畫 - 但關於屬性路徑 - 我試着添加.Children,正如你所建議的,我也刪除了第一個RotateTransform3D,因爲我意識到它不需要...繼承人我現在得到的... (Viewport2DVisual3D.Transform)。(Transform3DGroup.Children)[0]。(RotateTransform3D.Rotation)。(AxisAngleRotation3D.Angle) 但是現在它帶有'Rotation'屬性的錯誤不會指向依賴對象。你有什麼想法嗎? – 2009-12-09 13:46:07
同樣的錯誤我在使用Double Animation時也得到了相同的錯誤,這就是爲什麼我說要使用3D KeyFrame Animation而不是DoubleAnimation。沒有時間用3D KeyFrame Animation檢查它,你試試吧! – viky 2009-12-09 13:59:31