/// <summary> /// Invoked when another application wants to open files from this application. /// </summary> /// <param name="args">Activation data used to coordinate the process with Windows.</param> public void Activate(FileOpenPickerActivatedEventArgs args) { this._fileOpenPickerUI = args.FileOpenPickerUI; _fileOpenPickerUI.Closing += _fileOpenPickerUI_Closing; Messenger.Default.Register <PickerFileMessage>(this, pickerSelectionChanged); Window.Current.Content = this; Window.Current.Activate(); }
/// <summary> /// Invoked when another application wants to open files from this application. /// </summary> /// <param name="args">Activation data used to coordinate the process with Windows.</param> public void Activate(FileOpenPickerActivatedEventArgs args) { this._fileOpenPickerUI = args.FileOpenPickerUI; _fileOpenPickerUI.Closing += _fileOpenPickerUI_Closing; Messenger.Default.Register<PickerFileMessage>(this, pickerSelectionChanged); Window.Current.Content = this; Window.Current.Activate(); }
/// <summary> /// 在其他应用程序想要打开此应用程序中的文件时进行调用。 /// </summary> /// <param name="e">用于与 Windows 协调进程的激活数据。</param> public void Activate(FileOpenPickerActivatedEventArgs e) { this._fileOpenPickerUI = e.FileOpenPickerUI; _fileOpenPickerUI.FileRemoved += this.FilePickerUI_FileRemoved; // TODO: 将 this.DefaultViewModel["Files"] 设置为显示一个项集合, // 其中每个项都应有可绑定的 Image、Title 和 Description this.DefaultViewModel["CanGoUp"] = false; Window.Current.Content = this; Window.Current.Activate(); }
void _fileOpenPickerUI_Closing(Windows.Storage.Pickers.Provider.FileOpenPickerUI sender, Windows.Storage.Pickers.Provider.PickerClosingEventArgs args) { Messenger.Default.Unregister <PickerFileMessage>(this, pickerSelectionChanged); }
/// <summary> /// 当用户从选取器框中移除某一项目时调用 /// </summary> /// <param name="sender">用于包含可用文件的 FileOpenPickerUI 实例。</param> /// <param name="e">描述已移除文件的事件数据。</param> private void FilePickerUI_FileRemoved(Windows.Storage.Pickers.Provider.FileOpenPickerUI sender, Windows.Storage.Pickers.Provider.FileRemovedEventArgs e) { // TODO: 响应在选取器 UI 中取消选择的项。 }