Cannot resolve TargetName - Silverlight4 C#
- by Redburn
I am getting the error Cannot resolve TargetName grdGeneral. What I am trying to do is have a fade out function which accepts a grid and fades the opacity to zero. I have this function called on MouseLeftButtonDown and is loaded after the xaml and form has loaded.
Calling the fade out:
private void imgNext_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
fadeOut(grdGeneral);
}
The fade out function:
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();
}
I have been on a handful of tutorial sites and my code seems to follow the same order. I also have been on this stackoverflow question before you say repost. That question has to deal with mutlipages and I am merely trying to start a animation.
The Stack Trace
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 System.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: