Currently developing an Universal Windows Platform Application, can't access the parameter on the navigatedto page
Code for passing the parameter:
var ente = this.DataGrid.SelectedItem as Ente;
var Id = ente.Id;
Frame.Navigate(typeof(EntiEdit), Id);
and here's the "NavigatedTo" page
protected override void OnNavigatedTo(NavigationEventArgs e) {
string Id = e.Parameter as string;
}
How can i use this string in my other methods? The event override is protected so i can't access its content.
Thanks in advance
You should save the parameter to the class field or property to have access to it:
public class EntiEdit : Page
{
private string _entityId;
protected override void OnNavigatedTo(NavigationEventArgs e)
{
_entityId = e.Parameter as string;
}
}
If you need to initiate some handling after navigating the page you can do it from the event handler:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
var entityId = e.Parameter as string;
EntityData = LoadEntity(entityId);
DoSomeOtherRoutine(entityId);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With