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).

Christian Rondeau
  • 4,143
  • 5
  • 28
  • 46
  • Linking question http://stackoverflow.com/questions/12742558/search-pane-element-not-found-exception-in-win-8-app since it is the same error, but this question is with WPF – Christian Rondeau Sep 10 '14 at 02:41
  • You cannot use WinRT classes in a WPF app, this is supposed to fail. – Hans Passant Sep 10 '14 at 17:39
  • @HansPassant to you have a reference? There are articles on doing this on MSDN blogs (e.g. http://blogs.msdn.com/b/eternalcoding/archive/2013/10/29/how-to-use-specific-winrt-api-from-desktop-apps-capturing-a-photo-using-your-webcam-into-a-wpf-app.aspx) – Christian Rondeau Sep 11 '14 at 19:19
  • Actually, I found the reference myself: WinRT is supported, but SearchPane specifically is not supported... http://msdn.microsoft.com/en-us/library/windows.applicationmodel.search.searchpane.aspx – Christian Rondeau Sep 11 '14 at 19:21

1 Answers1

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

Christian Rondeau
  • 4,143
  • 5
  • 28
  • 46