2015-09-04 58 views
0

我正在使用windows phone 8.1應用程序。我打開一個fileOpenpicker使用下面的代碼。在windows phone 8.1中打開FileOpenPicker時的後退問題

FileOpenPicker _fileOpen = new FileOpenPicker(); 
view = CoreApplication.GetCurrentView(); 
_fileOpen.SuggestedStartLocation = PickerLocationId.VideosLibrary; 
_fileOpen.ViewMode = PickerViewMode.Thumbnail; 
_fileOpen.FileTypeFilter.Add("*"); 
_fileOpen.PickSingleFileAndContinue(); 

enter image description here

在當我按下後退按鈕這一點上,它關係到應用程序的主頁,而不是它被導航的頁面形式。請幫助

+0

你能告訴我們你處理BackPressedButton事件的代碼? –

+0

我還沒有處理過BackPressButton事件。 –

回答

3

是否在您試圖選擇文件的頁面中添加了IFileOpenPickerContinuable界面。此外,這將在以下方法中獲得文件選擇的結果。

public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args) 
{ 
    IReadOnlyList<StorageFile> files = args.Files; 
} 

看看打開此文件選擇器樣品在MSDN

https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn614994.aspx

1

1)打開App.xaml.cs文件

2)該代碼添加到應用程序()方法

HardwareButtons.BackPressed += HardwareButtons_BackPressed; 

3)粘貼此代碼如下應用()方法的地方

void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e) 
{ 
     Frame rootFrame = Window.Current.Content as Frame; 

     if (rootFrame.Content is MainPage) 
     { 
      rootFrame.BackStack.Clear(); 
     } 
     else if (rootFrame != null && rootFrame.CanGoBack) 
     { 
      rootFrame.GoBack(); 
     } 
     e.Handled = true; 
} 

它所做的是增加了處理按下硬件按鈕,如果用戶在MainPage那麼你離開一個應用程序。 如果您在這些代碼行中加了下劃線,那麼只需在其中的一個上設置文本光標,然後按Ctrl +'。'。 - >然後從菜單中選擇第一個選項以添加庫(使用表達式)。

相關問題