2013-03-28 68 views

回答

0

你當然可以添加命令到設備的魅力欄像這樣: 我假設你想添加到設置魅力欄。

創建一個類實例的AppSettings

public AppSetting() 
{ 
    SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested; 
    SizeChanged += AppSettingSizeChanged; 
} 


private void OnCommandsRequested(SettingsPane settingsPane, SettingsPaneCommandsRequestedEventArgs eventArgs) 
{ 
    eventArgs.Request.ApplicationCommands.Clear(); 

    UICommandInvokedHandler handler = new UICommandInvokedHandler(OnSettingsCommand); 

    // Some command 
    SettingsCommand someCommand = new SettingsCommand("uniqueID", "NameofLabel", handler); 
      eventArgs.Request.ApplicationCommands.Add(someCommand); 
} 



private void OnSettingsCommand(IUICommand command) 
{ 
    Logger.Log("Called"); 
    SettingsCommand settingsCommand = (SettingsCommand)command; 
    string id = settingsCommand.Id as string; 
    switch (id) 
     { 
     case someID: 
      { 
      ShowSomeUI(); 
      } break; 

     case otherID: 
      { 
      ShowSomeOtherUI(); 
      } break; 
     } 
} 

    protected void ShowSomeUI() 
    { 
//Implement anything you want here 
    } 

使用上面的類,使非常一流的您的應用程序從該類繼承,這樣的命令添加到魅力吧和執行他們的點擊任何東西。

P.S讓我知道如果這不明確或不回答你的問題。

+0

感謝分享代碼。它是自定義設置的魅力。我需要自定義「DEVICE CHARM」欄。 – Syed 2013-03-28 13:56:09

相關問題