locked
Problem using the Folder Picker in a Silverlight 8.1 app RRS feed

  • Question

  • Hi,

    I'm trying to use a Folder Picker in a Silverlight 8.1 app that was converted from 8.0.

    I read http://msdn.microsoft.com/en-us/library/windowsphone/develop/dn642086(v=vs.105).aspx  but had a problem with it:

    The catch lies in the Application_ContractActivated(object, IActivatedEventArgs ) event handler. In Silverlight however I get an Application_Activated(object, ActivatedEventArgs) event and the second parameter does not allow me to get the relevant members.

    Application_ContractActivated is a Windows Runtime lifetime event that's not available in Silverlight AFAIK.

    What to do?

    Thomas

    ) event with


    Monday, April 21, 2014 6:08 PM

Answers

  • When you create a new Silverlight 8.1 app these are added by the template but when upgrading an app you may need to add these manually...

    Manually add the event handler definition to your App.xaml.cs, ex:

    // Code to execute when a contract activation such as a file open or save picker returns 
    // with the picked file or other return values
    private void Application_ContractActivated(object sender, Windows.ApplicationModel.Activation.IActivatedEventArgs e)
    {
    }

    And hook this event handler in the InitializePhoneApplication() function of your App.xaml.cs, ex:

    // Handle contract activation such as a file open or save picker
    PhoneApplicationService.Current.ContractActivated += Application_ContractActivated;


    -Eric.

    • Marked as answer by t_s_b Tuesday, April 22, 2014 5:54 PM
    Monday, April 21, 2014 9:31 PM

All replies

  • When you create a new Silverlight 8.1 app these are added by the template but when upgrading an app you may need to add these manually...

    Manually add the event handler definition to your App.xaml.cs, ex:

    // Code to execute when a contract activation such as a file open or save picker returns 
    // with the picked file or other return values
    private void Application_ContractActivated(object sender, Windows.ApplicationModel.Activation.IActivatedEventArgs e)
    {
    }

    And hook this event handler in the InitializePhoneApplication() function of your App.xaml.cs, ex:

    // Handle contract activation such as a file open or save picker
    PhoneApplicationService.Current.ContractActivated += Application_ContractActivated;


    -Eric.

    • Marked as answer by t_s_b Tuesday, April 22, 2014 5:54 PM
    Monday, April 21, 2014 9:31 PM
  • To follow up on what Eric says, if you start with a Blank Windows Phone Silverlight 8.1 app and follow the steps in Continue your Windows Phone Silverlight 8.1 app after calling a file picker it works as described.

    --Rob

    Monday, April 21, 2014 9:38 PM
  • Hi,

    I'm trying to use a Folder Picker in a Silverlight 8.1 app that was converted from 8.0.

    I read  but had a problem with it:

    The catch lies in the Application_ContractActivated(object, IActivatedEventArgs ) event handler. In Silverlight however I get an Application_Activated(object, ActivatedEventArgs) event and the second parameter does not allow me to get the relevant members.

    Application_ContractActivated is a Windows Runtime lifetime event that's not available in Silverlight AFAIK.

    What to do?

    Thomas

    ) event with



    You need manually add the event handler definition to your App.xaml.cs. Don't copy!!!
    Sunday, November 16, 2014 10:42 AM