spiegelp / MaterialDesignExtensions

Material Design Extensions is based on Material Design in XAML Toolkit to provide additional controls and features for WPF apps
https://spiegelp.github.io/MaterialDesignExtensions/
MIT License
762 stars 122 forks source link

Stepper StepNavigation event System.ArgumentException #39

Closed slatimer580 closed 4 years ago

slatimer580 commented 5 years ago

I can't figure this one out.

I've added a Stepper to my project and it works just fine. When I to go add the StepNavigation event and then debug, it is throwing an exception.

System.ArgumentException: 'Object of type 'MaterialDesignExtensions.Controls.ActiveStepChangedEventArgs' cannot be converted to type 'MaterialDesignExtensions.Controls.StepValidationEventArgs'.'

I have no idea why this is happening. Any ideas?

spiegelp commented 5 years ago

@slatimer580 Could you post a full exception stack trace and the used NuGet packages with their version please?

hlysine commented 4 years ago

I am also having a similar problem, but it is the StepValidation event that is throwing the exception instead of StepNavigation (which works fine for me)

Stack trace:

Message: 
Object of type 'MaterialDesignExtensions.Controls.ActiveStepChangedEventArgs' cannot be converted to type 'MaterialDesignExtensions.Controls.StepValidationEventArgs'.

Stack Trace: 
   at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
   at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
   at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
   at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Windows.RoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   at MaterialDesignExtensions.Controls.Stepper.PropertyChangedHandler(Object sender, PropertyChangedEventArgs args)
   at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
   at MaterialDesignExtensions.Controllers.StepperController.OnPropertyChanged(String propertyName)
   at MaterialDesignExtensions.Controllers.StepperController.InitSteps(IStep[] steps)
   at MaterialDesignExtensions.Controllers.StepperController.InitSteps(IEnumerable`1 steps)
   at MaterialDesignExtensions.Controls.Stepper.InitSteps(IList values)
   at MaterialDesignExtensions.Controls.Stepper.LoadedHandler(Object sender, RoutedEventArgs args)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
   at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
   at MS.Internal.LoadedOrUnloadedOperation.DoWork()
   at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget)
   at System.Windows.Interop.HwndTarget.OnResize()
   at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(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 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Installed packages:

Id                                  Versions                                                                                                                                        
--                                  --------                                                                                                                                                  
cef.redist.x64                      {79.1.36}                                                                                                                                  
cef.redist.x86                      {79.1.36}                                                                                                                                    
CefSharp.Common                     {79.1.360}                                                                                                                                   
CefSharp.Wpf                        {79.1.360}                                                                                                                  
Costura.Fody                        {4.1.0}                                                                                                                         
Dragablz                            {0.0.3.203}                                                                                                                    
Fody                                {6.1.1}                                                                                                                    
MaterialDesignColors                {1.2.4}                                                                                                                              
MaterialDesignExtensions            {3.1.0}                                                                                                                                       
MaterialDesignThemes                {3.1.1}                                                                                                                                              
WinSCP                              {5.17.2}                         
spiegelp commented 4 years ago

@Henry-YSLin Thank you for the stack trace. I found the bug and just fixed the source code.

spiegelp commented 4 years ago

The latest pre-release v3.2.0-a01 contains the bugfix.