2012-08-31 2 views
0

메트로 응용 프로그램을 시작할 때 메트로 응용 프로그램에서 win32 바탕 화면을 입력하고 싶습니다 (메트로 시작 화면에서 응용 프로그램의 타일 누르기). 한 가지 방법은 메트로 앱을 시작할 때 파일 (예 : TXT 파일)을 여는 것입니다. OnLaunched에 다음 코드 로직을 추가합니다. 때로는 파일을 열고 데스크탑에 입력 할 수 있지만 때로는 그렇지 않습니다. 누군가 나를 도울 수 있습니까? (그냥 VS2012에서 빈 애플 리케이션을 만들).시작시 메트로 응용 프로그램에서 win32 바탕 화면에 입력하십시오.

async protected override void OnLaunched(LaunchActivatedEventArgs args) { 
// Do not repeat app initialization when already running, just ensure that the window  //is active 
if (args.PreviousExecutionState == ApplicationExecutionState.Running) 
{ 
    Window.Current.Activate(); 
    return; 
} 
if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) 
{ 
    //TODO: Load state from previously suspended application 
} 

// Create a Frame to act navigation context and navigate to the first page 
// var rootFrame = new Frame(); 
if (!rootFrame.Navigate(typeof(MainPage))) 
{ 
    throw new Exception("Failed to create initial page"); 
} 

// Place the frame in the current Window and ensure that it is active 
Window.Current.Content = rootFrame; 
Window.Current.Activate(); 
{ 
    string txtfile = @"Assets\a.txt"; 
    var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(txtfile); 

    if (file != null) 
    { 
     bool success = await Windows.System.Launcher.LaunchFileAsync(file); 
     if (success) 
     { 
     } 
     else 
     { 
     } 
    } 
} 

}

+0

시작했을 때 즉시 종료되는 WinForms 응용 프로그램을 만들어 보았습니까? – PhonicUK

답변

0

BatRT는 지하철 응용 프로그램에서 배치 파일을 실행할 수 있습니다. 이것은 메트로 앱에서 데스크탑 응용 프로그램을 실행하는 데 사용될 수 있습니다. 메트로 앱이 시작되면 원하는 데스크톱 애플리케이션을 실행하기위한 배치 파일을 실행하십시오.

관련 문제