2014-11-16 1 views
0

처음에는 빈 Windows Phone app 8.1 인 응용 프로그램에서 실제로 작업하고 있습니다. 나는 장치에서 그림을 얻기 위해 FileOpenPicker로 앱을 구현하고 싶다. WP 8.1에서는 PickSingleFileAndContinue OpenFilePicker 메서드를 사용해야합니다. 따라서 처리 할 프로젝트 구성에 대해 읽었습니다. 계속 이벤트는 your Windows Phone Store app after calling an AndContinue method MSDN입니다. 단계 중 하나는 app.xaml.cs 파일에 OnActivated 메서드를 구현하는 것입니다. 하지만 내 app.xaml.c에는 OnActivated 메소드가 없습니다. 나는 윈도우 폰에 알고 그냥 직면하고있어으로app.xaml.cs Windows Phone 8.1에 OnActivated 메서드가 없습니다.

protected async override void OnActivated(IActivatedEventArgs e) 
    { 
     base.OnActivated(e); 

     continuationManager = new ContinuationManager(); 

     Frame rootFrame = CreateRootFrame(); 
     await RestoreStatusAsync(e.PreviousExecutionState); 

     if (rootFrame.Content == null) 
     { 
      rootFrame.Navigate(typeof(MainPage)); 
     } 

     var continuationEventArgs = e as IContinuationActivatedEventArgs; 
     if (continuationEventArgs != null) 
     { 
      Frame scenarioFrame = MainPage.Current.FindName("ScenarioFrame") as Frame; 
      if (scenarioFrame != null) 
      { 
       // Call ContinuationManager to handle continuation activation 
       continuationManager.Continue(continuationEventArgs, scenarioFrame); 
      } 
     } 

     Window.Current.Activate(); 
    } 

:

는 나는 현재 상태가없는 위의 링크하지만 그 방법에 사용되는 MainPage 개체에서 그 방법을 붙여 복사 한 애플 리케이션의 상태 관리, 나는 그 오류가 어디서 왔는지 알 수 없다. 누군가가 아이디어를 얻었 을까요?

답변

1

전체 소스 코드 예제를 해당 링크에서 다운로드 할 때까지 100 % 클리어되지 않습니다. 그들은 전체 예제 (너무 많은 코드)를 게시하는 것을 소홀히했습니다. C# 데모 프로젝트를 다운로드하여보십시오. 당신은 그냥 정적 선언입니다 볼 수 있듯이

public sealed partial class MainPage : Page 
{ 
    public static MainPage Current;   

    public MainPage() 
    { 
     this.InitializeComponent();    

     // This is a static public property that allows downstream pages to get a handle to the MainPage instance 
     // in order to call methods that are in this class. 
     Current = this;    

     Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed; 
    } 
} 

MSDN FilePicker FULL SOURCE

.

+0

중요한 점은 MainPage.xaml 페이지가 필요 없기 때문에 삭제 한 것입니다. 그래서 빈 페이지가있는 것이 좋다고 생각했기 때문에 MainPage.xaml을 다시 만들었습니다. App.xaml.cs에서 여전히 동일한 오류가 발생하여 정적 MainPage 선언을 추가했습니다. ** MainPage는 "현재"구성 요소가 없으므로 강조 표시됩니다. ** –

+0

@HubertSolecki가 MainPage를 게시합니다. xaml.cs (전체 파일), 나는 이상한 일이 일어나지 않는 한 이런 일이 일어나는 것을 볼 수 없습니다. 또는 해당 파일을 삭제하고 추가 -> 새 항목 -> Visual C# -> Windows Phone 세로 페이지를 삭제할 수 있습니다. 그 이름은 MainPage.xaml입니다. –