Search code examples
c#wpfuwpdesktop-bridge

How can I open a File Dialog in WPF app that is being converted to a UWP app via Desktop App Converter


I have an app I created in WPF. Current in WPF, I'm using the Microsoft.Win32.SaveFileDialog file picker to let the user select a file location to save to.

I'm in the midst of converting this app to a Windows Store compatible app, via the Desktop App Converter application. When I use the Win32 picker in the UWP-converted app, it just hangs and eventually crashes, so that doesn't seem to be happy.

It looks like there is a UWP-compatible file picker Windows.Storage.Pickers.FileSavePicker, which is available using the Nuget package UWPDesktop.

Unfortunately, this is giving me the following warning -

Type 'Windows.Storage.Pickers.FileSavePicker' can only be used in UWP apps, not Desktop or Centennial

This seems pretty clear to me, so, finally my question is What dialog picker am I supposed to use for a desktop converter UWP app?

Seems like there are 2 options -

  1. There's some kind of 3rd type of file picker that I'm unaware of, that's compatible with both frameworks.
  2. I use some kind of check in the app to see what framework is active (somehow) and use the appropriate file picker.

Thanks in advance!


Solution

  • I ended up building a sample app containing just the problematic dialog in an otherwise empty app, with the plan of sending it to Stefan over MS.

    Of course, everything looked good, so I played with it a little more and eventually figured out what might have happened.

    I was running some async code just before the dialog was executed, and it looks like that would fail silently, causing the app to hang indefinitely.

    I don't think this will help anyone, just wanted to close the loop.