gpt4 book ai didi

wpf - 找不到 EventTrigger.SourceName

转载 作者:行者123 更新时间:2023-12-02 01:17:10 31 4
gpt4 key购买 nike

<Canvas>
<Button Name="b1" Content="Button"/>
<Rectangle Name="Mr1" Fill="Black">
<Rectangle.Triggers>
<EventTrigger SourceName="b1" RoutedEvent="Button.Click">
<BeginStoryboard>
<code.../>
</BeginStoryboard>
</EventTrigger>
</Rectangle.Triggers>
</Rectangle>
</Canvas>

错误:找不到 b1。

请帮帮我,谢谢。

最佳答案

我刚遇到同样的问题.. 为其他感兴趣的人发布解决方案。

<Canvas>

<Canvas.Resources>
<Storyboard x:Key="MyAwesomeAnimation" Storyboard.TargetName="Mr1" Storyboard.TargetProperty="Height">
<!-- Some Awesome animation here..-->
</Storyboard>
</Canvas.Resources>

<Button Name="b1" Content="Button">
<Button.Triggers>
<!--The key is to define the click trigger on the button. Why should the rectangle know about the button?-->
<EventTrigger RoutedEvent="Button.Click">
<BeginStoryboard Storyboard="{StaticResource MyAwesomeAnimation}"></BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>

<Rectangle Name="Mr1" Fill="Black" />

</Canvas>

关于wpf - 找不到 EventTrigger.SourceName,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10067621/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com