diff --git a/src/dxaml/xcp/core/core/elements/depends.cpp b/src/dxaml/xcp/core/core/elements/depends.cpp index 0b42f0cab9..4ca3a52057 100644 --- a/src/dxaml/xcp/core/core/elements/depends.cpp +++ b/src/dxaml/xcp/core/core/elements/depends.cpp @@ -323,7 +323,7 @@ wrl::ComPtr CDependencyObject::GetElementIsla return spPopup->GetIslandInputSite(); } - if (coreServices->HasXamlIslandRoots()) + if (coreServices && coreServices->HasXamlIslandRoots()) { // If this element is in a XamlIslandRoot tree, return the IslandInputSite for that island. auto root = coreServices->GetRootForElement(this); @@ -336,7 +336,15 @@ wrl::ComPtr CDependencyObject::GetElementIsla } // By default, return the primary IslandInputSite that was registered with InputServices on startup. - return coreServices->GetInputServices()->GetPrimaryRegisteredIslandInputSite(); + if (coreServices) + { + if (auto inputServices = coreServices->GetInputServices()) + { + return inputServices->GetPrimaryRegisteredIslandInputSite(); + } + } + + return nullptr; } HWND CDependencyObject::GetElementPositioningWindow()