Cannot open the Windows Search Pane in WPF: Element not found. (Exception from HRESULT: 0x80070490)

1

I have a WPF project with only these changes from an empty project:

  • This line added to the .csproj: <TargetPlatformVersion>8.0</TargetPlatformVersion>
  • A reference added to Windows
  • A button with a Click handler executing this: SearchPane.GetForCurrentView().Show("test");

When I click the button, I have an exception when calling .GetForCurrentView():

Element not found. (Exception from HRESULT: 0x80070490)

What can I do to diagnose it and make it work?


Details:

Note that I have no breakpoints, I'm running on Windows 8.1 and I already tried:

  • Adding await BackgroundExecutionManager.RequestAccessAsync(); before;
  • Adding a 1000ms delay;
  • Referencing System.Runtime, System.Runtime.WindowsRuntime and System.Runtime.InteropServices.WindowsRuntime

I know I can use SendKeys to send Win + S + (query), but this is exactly what I'm trying to replace since at the moment I try to open the search charm, the Ctrl key will be down (launched by a shortcut).

c#
wpf
windows-8
windows-runtime
charms-bar
asked on Stack Overflow Sep 10, 2014 by Christian Rondeau • edited Sep 10, 2014 by Christian Rondeau

1 Answer

0

Even though some WinRT API functions can be used in a desktop app, SearchPane cannot.

MSDN pages show whether each individual API function can be used or not in Desktop apps: http://msdn.microsoft.com/en-us/library/windows.applicationmodel.search.searchpane.aspx

answered on Stack Overflow Sep 20, 2014 by Christian Rondeau

User contributions licensed under CC BY-SA 3.0