im using blend 4 to make a wpf application
i have a wrapPanel defined in xaml:
<WrapPanel x:Name="WrapPanel_ShowMe">
when i enter a certain visual state, the code-behind the wrapPanel to a new location:
WrapPanel_ShowMe.RenderTransform = new TranslateTransform(0,-661.5);
im doing it this way because in this state different wrapPanels can appear in the state, (to save from duplicating the state)
after i exit the state, i move the panel back to its origional location.
I also have the same wrapPanel being moved by xaml in other states:
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="WrapPanel_ShowMe">
<EasingDoubleKeyFrame KeyTime="0" Value="-648"/>
</DoubleAnimationUsingKeyFrames>
so state A moves the wrapPanel in c#, and State B moves the panel using xaml.
When i use state B, the wrapPanel moves like it should with no problems. (xaml)
When i use state A, the wrapPanel moves like it should with no problems. (c#)
the problem occurs when i use state A to move the panel and THEN try to use state B afterwords. The program crashes, and I have no idea why. It seems that after using the code-behind to move the object, the xaml render transform is no longer valid?
can anyone tell me why this might be and how to fix/get around it?
Thanks in advance
EDIT
the stack results are as follows:
Unhandled Exception: System.InvalidOperationException: 'Children' property value in the path '(0).(1)[3].(2)' points to immutable instance of 'System.Windows.Media.TransformCollection'.
at System.Windows.Media.Animation.Storyboard.VerifyPathIsAnimatable(PropertyPath path)
at System.Windows.Media.Animation.Storyboard.ClockTreeWalkRecursive(Clock currentClock, DependencyObject containingObject, INameScope nameScope, DependencyObject parentObject, String parentObjectName, PropertyPath parentPropertyPath, HandoffBehavior handoffBehavior, HybridDictionary clockMappings, Int64 layer)
at System.Windows.Media.Animation.Storyboard.ClockTreeWalkRecursive(Clock currentClock, DependencyObject containingObject, INameScope nameScope, DependencyObject parentObject, String parentObjectName, PropertyPath parentPropertyPath, HandoffBehavior handoffBehavior, HybridDictionary clockMappings, Int64 layer)
at System.Windows.Media.Animation.Storyboard.BeginCommon(DependencyObject containingObject, INameScope nameScope, HandoffBehavior handoffBehavior, Boolean isControllable, Int64 layer)
at System.Windows.VisualStateGroup.StartNewThenStopOld(FrameworkElement element, Storyboard[] newStoryboards)
at System.Windows.VisualStateManager.GoToStateInternal(FrameworkElement control, FrameworkElement stateGroupsRoot, VisualStateGroup group, VisualState state, Boolean useTransitions)
at Microsoft.Expression.Interactivity.Core.ExtendedVisualStateManager.TransitionEffectAwareGoToStateCore(FrameworkElement control, FrameworkElement stateGroupsRoot, String stateName, VisualStateGroup group, VisualState state, Boolean useTransitions, VisualTransition transition, Boolean animateWithTransitionEffect, VisualState previousState)
at Microsoft.Expression.Interactivity.Core.ExtendedVisualStateManager.GoToStateCore(FrameworkElement control, FrameworkElement stateGroupsRoot, String stateName, VisualStateGroup group, VisualState state, Boolean useTransitions)
at System.Windows.VisualStateManager.GoToStateCommon(FrameworkElement control, FrameworkElement stateGroupsRoot, String stateName, Boolean useTransitions)
at Microsoft.Expression.Interactivity.VisualStateUtilities.GoToState(FrameworkElement element, String stateName, Boolean useTransitions)
at System.Windows.Interactivity.TriggerBase.InvokeActions(Object parameter)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run()
at TrailerUnitNewTutor_1.App.Main() in c:\Users\Domnick\Documents\Expression\Blend 4\Projects\TrailerUnitNewTutor_1\TrailerUnitNewTutor_1\obj\Debug\App.g.cs:line 0