我正在尝试为MyAnimation进行绑定工作,类似于MyHeight的工作。 我的身高正常,但我无法找到让MyAnimation与某事结合的方法。
<DataTemplate
x:Key="MyTemplate"
DataType="MyNotification">
<Grid
x:Name="MyNotificationWindow" ...
Height="{Binding Path = MyHeight}"
>
....
</Grid>
<DataTemplate.Triggers>
<EventTrigger
RoutedEvent="Window.Loaded"
SourceName="MyNotificationWindow">
<BeginStoryboard
x:Name="MyStory">
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="MyNotificationWindow"
From="0.01"
To="1"
Storyboard.TargetProperty="Opacity"
Duration="{Binding Path=MyAnimation, RelativeSource={RelativeSource TemplatedParent}}"
/>
....
</DataTemplate.Triggers>
谢谢!
答案 0 :(得分:0)
我认为问题如下:{Binding Path=MyAnimation, RelativeSource={RelativeSource TemplatedParent}}
应为{Binding Path=DataContext.MyAnimation, RelativeSource={RelativeSource Self}}
试试这个,可能是个问题。