2016-09-30 8 views
0

私はタイル作成をアプリケーション内に統合しました。c#UWP - タイルOnNavigatedToはメインページの変数を保持しません

タイルはきれいに作成されます。私は、アプリケーションがタイルから起動されるときに使用する文字列パラメータを設定します。

  string tileActivationArguments = "test_params"; 

      SecondaryTile s = new SecondaryTile(name_clean, 
                   name, 
                   name, 
                   tileActivationArguments, 
                   TileOptions.ShowNameOnLogo, 
                   logo); 


      s.DisplayName = name; 
      s.ForegroundText = ForegroundText.Dark; 
      bool isPinned = await s.RequestCreateForSelectionAsync(MainPage.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Below); 

そして、それは大成功で固定です:私のClass.xaml.cs

スタートアップメニューからタイルをクリックすると、MainPage.OnNavigatedToに到着します。ここでは、パラメータは存在しており、ローカル変数に設定しています。

MainPage.xaml.cs

private string params; 

    protected override async void OnNavigatedTo(NavigationEventArgs e) 
    { 
     var parametters = e.Parameter as string; 
     if (parametters != null && parametters != "") 
     { 
      params = parametters ; // WORKS: here params has the good parameter string 
      .... 
     } 
    } 

そして、それは、メインページ()

public MainPage() 
    { 
     this.InitializeComponent(); 

     // here the params seems to be reset 
     Debug.WriteLine(params); // Exception 
     // params == null 
    ... 
    } 

に任意のアイデアを行きますか?

答えて

0

コンストラクタは常に最初に呼び出されますOnNavigatedToこの時点では、paramsはまだNULLです

関連する問題