简体   繁体   中英

Windows phone filepicker

I have a problem with FilePicker in Windows Phone 8.1

I'm set up a FilePicker object like that:

                FileOpenPicker filePicker = new FileOpenPicker();
                filePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
                filePicker.ViewMode = PickerViewMode.List;
                filePicker.FileTypeFilter.Add(".xml");
                filePicker.FileTypeFilter.Add(".txt");
                filePicker.PickSingleFileAndContinue();

                view.Activated += View_Activated;

Before that I'm setting up a view object:

view = CoreApplication.GetCurrentView();

File Picker is invoked properly, I'm selecting a file, after that I got unhandled exception in App class.

"Error in line 1 position 229. Element ' http://schemas.microsoft.com/2003/10/Serialization/Arrays:anyType ' contains data of the ' http://schemas.datacontract.org/2004/07/SQLite:Task ' data contract. The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'Task' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer."

View_Activated method is never invoked.

What can be wrong?

You shouldn't be using the activated for the page. The activation process should start in the App.xaml.cs

Check this link for SilverLight: https://msdn.microsoft.com/en-us/library/windows/apps/dn642086(v=vs.105).aspx

Check this link for normal: https://www.jayway.com/2014/04/16/windows-phone-8-1-for-developers-contracts/

You are not showing the code that generates the error. Based on the error you should show us the code that handles the selected file. The error says that the XML could not be parsed. So the file is selected, just not parsed correctly

I think the timeline is: FilePicker => Parse => View

Since the error is in the Parsing, the view is never activated

If you need help with the parsing error you should ask a new question with the parsing code in it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM