Reputation: 1467
I get the following error:
0x800a138f - JavaScript runtime error: Unable to get property 'activate' of undefined or null reference
when running the following line of javascript in my UWP App:
Windows.UI.Xaml.Window.activate();
Windows.UI.Xaml.Window.current.activate();
or
Windows.UI.Core.CoreWindow.activate();
API Reference, Handle app activation Doc
Upvotes: 0
Views: 744
Reputation: 21899
Windows.Ui.Xaml and the docs you linked aren't relevant for HTML/JavaScript apps. Windows.UI.Xaml is used only in Xaml apps.
To call activate You need a Windows.UI.Core.CoreWindow object, but Windows.UI.Core.CoreWindow itself is logically a class not an object
You need to create or acquire an instance of the class to call activate. To get such an object call CoreWindow's static method getForCurrentThread
var window = Windows.UI.Core.CoreWindow.getForCurrentThread();
Window.activate();
That said, what problem are you actually trying to solve? Why are you calling this? Initial window activation in JavaScript apps is handled by framework code not called explicitly by app code. Unless you're managing multiple CoreWindows in your app, attempts to activate the window will depend on it already being active: you can't force your window on the user.
Upvotes: 1