简体   繁体   English

从DataTemplate.Triggers进行绑定

[英]Binding from DataTemplate.Triggers

I am trying to do my binding working for MyAnimation similar to the working one which is MyHeight. 我正在尝试为MyAnimation进行绑定,类似于正在工作的MyHeight。 My Height is working properly, but I can not find a way to make the MyAnimation binds to something. 我的身高正常工作,但是我找不到使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>

Thank you! 谢谢!

I think the issue is the following : {Binding Path=MyAnimation, RelativeSource={RelativeSource TemplatedParent}} should be {Binding Path=DataContext.MyAnimation, RelativeSource={RelativeSource Self}} 我认为问题如下: {Binding Path=MyAnimation, RelativeSource={RelativeSource TemplatedParent}}应该是{Binding Path=DataContext.MyAnimation, RelativeSource={RelativeSource Self}}

Try this, it might be the issue. 试试这个,可能是问题所在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM