0

Windows Photo Viewer와 유사한 메트로 스타일 앱을 만들려고합니다.메트로 스타일 앱 만들기 및 열린 컨텍스트 메뉴에 추가하기

그 때문에 Openwith 컨텍스트 메뉴에서 내 응용 프로그램을 추가해야합니다. 또한 Windows 탐색기에서 선택한 이미지 파일이 내 사진 뷰어에서 열립니다. 선택한 이미지 파일을 매개 변수로 사용하여 앱을 여는 방법은 무엇입니까? 사전에

덕분에


덕분에

@Filip 많은 내 응용 프로그램은 개방에 아무것도 표시되지 않습니다, App.xaml.cs

protected override void OnFileActivated(FileActivatedEventArgs args) 
     { 
      // TODO: Handle file activation 

      // The number of files received is args.Files.Size 
      // The first file is args.Files[0].Name 
      base.OnFileActivated(args); 
      StorageFile file = args.Files[0] as StorageFile; 

      Frame rootFrame = Window.Current.Content as Frame; 

      if (rootFrame == null) 
      { 
       // Create a Frame to act as the navigation context and navigate to the first page 
       rootFrame = new Frame(); 
       //rootFrame.SourcePageType = typeof(ImageViewer); 

       if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) 
       { 
        //TODO: Load state from previously suspended application 
       } 

       // Place the frame in the current Window 
       Window.Current.Content = rootFrame; 
      } 

      if (rootFrame.Content == null) 
      { 
       // When the navigation stack isn't restored navigate to the first page, 
       // configuring the new page by passing required information as a navigation 
       // parameter 
       if (!rootFrame.Navigate(typeof(ImageViewer), file)) 
       { 
        throw new Exception("Failed to create initial page"); 
       } 
      } 
      // Ensure the current window is active 
      Window.Current.Activate(); 
     } 

OnFileActivated(FileActivatedEventArgs args)에 다음 코드를 작성하지만, . 그래서 당신에 따르면 무엇이 결함이 될 수 있습니까?

답변

0

매니페스트 편집기의 선언 탭에 Package.appxmanifest를 추가하여 파일 형식 연결을 추가하면 앱이 지정한 파일 형식을 열 수있는 앱 중 하나가됩니다. this article에 설명 된대로 파일 활성화를 처리하기 위해 App 클래스에 재정의를 추가하면됩니다.

protected override void OnFileActivated(FileActivatedEventArgs args) 
{ 
    // TODO: Handle file activation 

    // The number of files received is args.Files.Size 
    // The first file is args.Files[0].Name 
} 
관련 문제