首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从DataTemplate.Triggers绑定

从DataTemplate.Triggers绑定
EN

Stack Overflow用户
提问于 2014-02-04 22:32:02
回答 1查看 51关注 0票数 0

我正在尝试为MyAnimation做绑定工作,类似于工作中的MyHeight。我的身高正常工作,但我找不到一种方法使MyAnimation绑定到某个东西上。

代码语言:javascript
复制
    <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>

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2014-02-04 22:42:21

我认为问题是这样的:{Binding Path=MyAnimation, RelativeSource={RelativeSource TemplatedParent}}应该是{Binding Path=DataContext.MyAnimation, RelativeSource={RelativeSource Self}}

试试这个,这可能就是问题所在。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21555240

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档