diff --git a/dev/CommandBarFlyout/CommandBarFlyout.cpp b/dev/CommandBarFlyout/CommandBarFlyout.cpp index 9af0107f0d..f05feba4bd 100644 --- a/dev/CommandBarFlyout/CommandBarFlyout.cpp +++ b/dev/CommandBarFlyout/CommandBarFlyout.cpp @@ -251,11 +251,14 @@ CommandBarFlyout::CommandBarFlyout() args.Cancel(true); commandBar->PlayCloseAnimation( - [this]() + [weakThis{ get_weak() }]() { - m_isClosingAfterCloseAnimation = true; - Hide(); - m_isClosingAfterCloseAnimation = false; + if (auto strongThis = weakThis.get()) + { + strongThis->m_isClosingAfterCloseAnimation = true; + strongThis->Hide(); + strongThis->m_isClosingAfterCloseAnimation = false; + } }); } else