HTML and CSS Reference
In-Depth Information
If the application is not in a snapped state, then you are ready to invoke the system's picker for
saving a file.
Dealing with the default File save picker
Windows 8 provides two distinct components whether you need to pick the file to save or read some
content. You use the Windows.Storage.Pickers.FileOpenPicker object if your goal is picking an existing
file for reading its content. You use the Windows.Storage.Pickers.FileSavePicker object, instead, if
you intend to create a new file or override an existing one. To save the task, you opt for the second
option. This is the code you need to have in the TodoList.pickFileAndSaveTask function within the
todolist.js file
TodoList.pickFileAndSaveTask = function () {
// Code to check if in snapped state
// Get the task object to save
var currentTask = TodoList.getTaskFromUI();
// Create the picker object and set options
var savePicker = new Windows.Storage.Pickers.FileSavePicker();
savePicker.commitButtonText = "Create task";
savePicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.
savePicker.suggestedFileName = currentTask.description;
savePicker.fileTypeChoices.insert("TodoList Task", [".todo"]);
// More code will go here
This code is not sufficient yet to display the user interface for picking up files. It lacks the specific
instruction that pops up the standard user interface. Let's spend a few moments understanding the
role of the properties involved in the code above.
preferred settings
You should notice that the SuggestedStartLocation property is set to an expression that indicates the
Computer folder as the starting location of the search. As the property name seeks to indicate, that
is not necessarily going to be the real start location for the file picker. In an attempt to give users a
continuous feel, the file picker tracks the last folder visited and starts from there. Should the folder
be unavailable (such as, the folder has been deleted) or unreachable (such as, you are disconnected
from the network), then the picker will take the suggestion. The suggestion is also taken if there's no
current record on track about the last folder visited.
Search WWH ::

Custom Search