I've just integrated the Tile creation within my application.
The Tiles are created just fine. I set a string parameter to use when the app is launched from the Tile.
in my Class.xaml.cs :
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);
And it's pinned with succes.
But when I click on the Tile from the startup menu, I arrive on MainPage.OnNavigatedTo
and here, the params are existing, and I set them on a local variable.
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
....
}
}
then, it goes into MainPage()
public MainPage()
{
this.InitializeComponent();
// here the params seems to be reset
Debug.WriteLine(params); // Exception
// params == null
...
}
Any Ideas ?
构造函数始终在OnNavigatedTo
之前OnNavigatedTo
调用,此时params
仍为null
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.