c# – XAML定义的StoryBoard在C中调用时抛出nullpointer
发布时间:2020-12-16 02:03:06 所属栏目:百科 来源:网络整理
导读:我正在尝试为按钮设置动画,以便当用户触摸它时图像会放大并在发布时恢复正常但是在C#中调用时,XAML Defined StoryBoard会以某种方式抛出nullpointer.我的代码片段在这里,我根本不知道是什么造成了这个问题. XAML: UserControl x:Class="Mavie_Base.GUIEleme
我正在尝试为按钮设置动画,以便当用户触摸它时图像会放大并在发布时恢复正常但是在C#中调用时,XAML Defined StoryBoard会以某种方式抛出nullpointer.我的代码片段在这里,我根本不知道是什么造成了这个问题.
XAML: <UserControl x:Class="Mavie_Base.GUIElements.MenuButton" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" d:DesignHeight="200" d:DesignWidth="140"> <UserControl.Resources> <Storyboard x:Name="Enlarge"> <DoubleAnimation Duration="0:0:1" From="60" To="66" Storyboard.TargetProperty="Height" Storyboard.TargetName="Rectangle"/> </Storyboard> <Storyboard x:Name="Normalize"> <DoubleAnimation Duration="0:0:1" From="66" To="60" Storyboard.TargetProperty="Height" Storyboard.TargetName="Rectangle"/> </Storyboard> </UserControl.Resources> .... </UserControl> C#: private void IconContainer_MouseEnter(object sender,System.Windows.Input.MouseEventArgs e) { Enlarge.Begin(); } private void IconContainer_MouseLeave(object sender,System.Windows.Input.MouseEventArgs e) { Normalize.Begin(); } 解决方法
尝试转换targetproperty:
Storyboard.TargetProperty="(FrameworkElement.Height)" (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |