故事板在代码隐藏中不可用
为什么我使用 WPF 时无法访问情节提要。在 Silverlight 中,完全相同的代码也可以工作。
VB
Public Class UserControl1
Private Sub UserControl1_MouseLeftButtonDown(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Handles Me.MouseLeftButtonDown
Me.storyboardBlend.Begin()
End Sub
End Class
XAML 隐藏代码:
<UserControl x:Class="UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Image x:Name="imgOn" Source="/OUTPUT%20-%20WPF01;component/Images/Disk.png" />
<Grid.Resources>
<Storyboard x:Key="storyboardBlend" x:Name="storyboardBlend">
<DoubleAnimation x:Name="AnimationOpacityOn" Storyboard.TargetName="imgOn" Storyboard.TargetProperty="Opacity" Duration="0:0:1.500" To="1" />
</Storyboard>
</Grid.Resources>
</Grid>
</UserControl>
Why can I not access to the storyboard when using WPF. In Silverlight, the exact same code works.
Codebehind VB
Public Class UserControl1
Private Sub UserControl1_MouseLeftButtonDown(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Handles Me.MouseLeftButtonDown
Me.storyboardBlend.Begin()
End Sub
End Class
XAML:
<UserControl x:Class="UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Image x:Name="imgOn" Source="/OUTPUT%20-%20WPF01;component/Images/Disk.png" />
<Grid.Resources>
<Storyboard x:Key="storyboardBlend" x:Name="storyboardBlend">
<DoubleAnimation x:Name="AnimationOpacityOn" Storyboard.TargetName="imgOn" Storyboard.TargetProperty="Opacity" Duration="0:0:1.500" To="1" />
</Storyboard>
</Grid.Resources>
</Grid>
</UserControl>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
现在可以使用字符串作为故事板的键。但我仍然无法访问下一步的动画参数。
XAML 部分:
Hack in Codebehind 不起作用:
To use a string as key works now for the storyboard. But I have still no access to the animation parameter which is the next step.
XAML part:
Hack in Codebehind which is not working: