If I have to pass an object from one page to another in wp8.What should be done? As For passing string or int values we use querystring.Can we do the same for passing the object:-
Vehicle vm = item as Vehicle;
NavigationService.Navigate(new Uri("/Page2.xaml?values=" + vm, UriKind.Relative));and in the other class:-
var values1="";
if (NavigationContext.QueryString.TryGetValue("values", out values1)){ //do something with the parameter }
Selva GanapathyPosted Dec 8, 2014, 3:46 AM
Hi Sweta Sinha,
Try this,
private object navigationParam = null;
protected object Parameter{get;private set;}
protected void Navigate(string url, object paramter = null)
{
navigationParam = paramter;
this.NavigationService.Navigate(new Uri(url, UriKind.Relative));
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
if (e.Content is PhoneApplicationBasePage )
{
PhoneApplicationBasePage appPage = e.Content as PhoneApplicationBasePage;
if (appPage != null)
{
appPage (navigationParam);
navigationParam =null;
}
}
}
private void SendParameter(object param)
{
if (this.Parameter == null)
{
this.Parameter = param;
this.OnParameterReceived();
}
}
protected virtual void OnParameterReceived()
{
}
Regards,
Selva Ganapathy K