我正在尝试为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>谢谢!
发布于 2014-02-04 22:42:21
我认为问题是这样的:{Binding Path=MyAnimation, RelativeSource={RelativeSource TemplatedParent}}应该是{Binding Path=DataContext.MyAnimation, RelativeSource={RelativeSource Self}}
试试这个,这可能就是问题所在。
https://stackoverflow.com/questions/21555240
复制相似问题