locked
Using Filepicker with apps converted form WP 8 to WP 8.1 RRS feed

  • Question

  • Hi,

    I have converted a XAML/C# Windows Phone 8 app to 8.1. Now I want to use the "FileOpenPicker" in my app as described here: http://msdn.microsoft.com/en-us/library/windowsphone/develop/dn614994.aspx.

    The file pickers seem to require that the App extends "Windows.UI.Xaml.Application" from the ".NET for Windows Store app" framework to get the picking result (e.g. by overwritting the "OnActivated" method). The problem is that the converted app project imports the ".NET for Windows Phone" framework and there is no access to "Windows.UI.Xaml.*".

    Is it possible to make the file pickers work in the converted app without having to create a new project and copy everything to this new project?

    Regards,


    • Edited by SyFr Monday, April 28, 2014 8:42 AM
    Monday, April 28, 2014 8:41 AM

All replies

  •  The FileOpenPicker class is available in Windows.Storage.Pickers namespace not in the XAML namespace. If your app was successfully converted to Windows Phone Silverlight 8.1, then you should be able to use that class/namespace.

    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    Monday, April 28, 2014 6:42 PM
  • Yes, but in contrast to Windows 8.1, the pickers in WP 8.1 are not awaitable but use a "continuation" mechanism which suspends the app and passes the picked file as an arguement:

    protected async override void OnActivated(IActivatedEventArgs e)
            {
                Debug.WriteLine("OnActivated: " + e.PreviousExecutionState.ToString());
    
                CreateRootFrame();
    
                // Restore the saved session state only when appropriate
                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        //Something went wrong restoring state.
                        //Assume there is no state and continue
                    }
                }
    
                //Check if this is a continuation
                var continuationEventArgs = e as IContinuationActivatedEventArgs;
                if (continuationEventArgs != null)
                {
                    ContinuationManager.Continue(continuationEventArgs);
                }
    
                Window.Current.Activate();
            }
    
    

    Tuesday, April 29, 2014 4:59 AM
  • Hopefully this link should help with your issue: http://blogs.msdn.com/b/wsdevsol/archive/2014/05/08/using-the-andcontinue-methods-in-windows-phone-silverlight-8-1-apps.aspx

    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    Tuesday, May 27, 2014 11:18 PM