大佬教程收集整理的这篇文章主要介绍了无法解析TargetName – Silverlight4 C#,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
呼唤淡出:
private void imgNext_MouSELEftButtonDown(object sender,MouseButtonEventArgs E) { fadeOut(GrdGeneral); }
淡出功能:
private void fadeOut(Grid pGrid) { Storyboard stb = new Storyboard(); DoubleAnimation da = new DoubleAnimation(); da.From = 1.0; da.To = 0.0; stb.Duration = new Duration(TimeSpan.FromSeconds(.75)); stb.Children.Add(da); Storyboard.SetTargetName(da,pGrid.Name); Storyboard.SetTargetProperty(da,new PropertyPath(Grid.opacityProperty)); stb.begin(); }
我一直在一些教程网站上,我的代码似乎遵循相同的顺序.在你说重新发布之前,我也一直在这个stackoverflow question上.这个问题必须处理多个问题,我只是想开始动画.
堆栈跟踪
system.invalidoperationException was unhandled by user code message=CAnnot resolve TargetName GrdGeneral. StackTrace: at Ms.Internal.XcpImports.MethodEx(IntPtr ptr,String name,CValue[] cvData) at Ms.Internal.XcpImports.MethodEx(DependencyObject obj,String Name) at Sy@L_944_15@.Windows.Media.Animation.Storyboard.begin() at MeterTesTing.QuarterReportGUI.fadeOut(Grid pGrid) at MeterTesTing.QuarterReportGUI.imgNext_MouSELEftButtonDown(Object sender,MouseButtonEventArgs E) at Ms.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex,Delegate handlerDelegate,Object sender,Object args) at Ms.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj,IntPtr unmanagedObjArgs,Int32 argsTypeIndex,String eventName) InnerException:
您应该在xaml中执行此操作,最好使用Blend.在你的xaml中尝试这个:
<UserControl.resources> <Storyboard x:Name="FadeGrid"> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.opacity)" Storyboard.TargetName="GrdGeneral"> <EasingDoubleKeyFrame KeyTime="0" Value="1"/> <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="0"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </UserControl.resources> <Grid x:Name="GrdGeneral" BACkground="White"> <Image x:Name="imgNext" MouSELEftButtonDown="imgNext_MouSELEftButtonDown" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" source="/StoryboardInCode;component/Images/avatar.jpg"></Image> </Grid>
private void imgNext_MouSELEftButtonDown(object sender,MouseButtonEventArgs E) { FadeGrid.begin(); }
这应该会给你你想要的东西.
使用按钮代替图像也会更好.
以上是大佬教程为你收集整理的无法解析TargetName – Silverlight4 C#全部内容,希望文章能够帮你解决无法解析TargetName – Silverlight4 C#所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。