Skip to content

[Bug] Opening a content dialog with an expander with ExpanderCardStyleKey throws System.NullReferenceException #421

@Zaitonn

Description

@Zaitonn

Describe the bug

如题。

先在一个ContentDialog里头塞个Expander,然后给他的Style设置{StaticResource {x:Static ui:ThemeKeys.ExpanderCardStyleKey}},然后show一下就抛异常了

Place an Expander inside a ContentDialog, then set its Style to {StaticResource {x:Static ui:ThemeKeys.ExpanderCardStyleKey}}, and a NullReferenceException is thrown when the dialog is shown.

Image
堆栈信息 / Stack info
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at iNKORE.UI.WPF.Modern.Controls.Helpers.ExpanderAnimationsHelper.UpdateLayout(FrameworkElement contentControl)
   at iNKORE.UI.WPF.Modern.Controls.Helpers.ExpanderAnimationsHelper.AnimateCollapse(Expander expander)
   at iNKORE.UI.WPF.Modern.Controls.Helpers.ExpanderAnimationsHelper.RunExpanderAnimation(Expander expander)    
   at iNKORE.UI.WPF.Modern.Controls.Helpers.ExpanderAnimationsHelper.<>c__DisplayClass12_0.<OnIsEnabledChanged>g__TriggerExpandAnimationOnLoad|0(Object sender, 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.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)        
   at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
   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.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)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   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)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(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.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at Test.App.Main()

Reproduction

App.zip

just run the project and click the button in the center of the window

Suggested Solution

No response

Library Version

0.10.2

Operating System

Windows 11

Framework

.NET Core and .NET

Framework Version

8.0.22

Source of Package

NuGet.org (Package)

Additional Notes

var toAnimateControl = GetToAnimateControl(expander);

感觉是这个的问题?🤔

Image

Validations

  • Check that there isn't already an issue that reports the same or similar problem.
  • Check that this is a bug in the library that should be fixed, not a feature, also this is not about the documentation. (Or please choose the right repo and template.)
  • This is one single problem, or a few problems with the same cause. (If you want to report multiple problems, please create one issue for every single problem.)
  • You've checked that this problem still exists in the latest version. (Keep in mind that we don't provide any support for old versions.)
  • You know that we can't guarantee that we will satisfy your request. This is not really our duty to do everything anyone asks for. Also, you will treat our staff, contributors, and other users with respect and kindness.
  • You're sure there's something wrong with the library itself, not how you're using it. (If you are having issues using it and need help, please go to discussion.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions