I have searched for this, but wasn't able to find anything directly related to the Windows Phone 8.1 Environment, please let me know if there is a link available as I would have thought this would be a common question..
I am trying to navigate to another page from within a UserControl when an Item in a list is tapped, however, I am having troubling getting Parent page's Frame so I can navigate.
Essentially, I am trying to do this within the User Control.
private void lstFoo_ItemClick(object sender, ItemClickEventArgs e)
{
Page parentPage = this.Parent as Page; //Returns null
if (parentPage != null)
{
parentPage.Frame.Navigate(typeof(BarPage), e.ClickedItem);
}
}
The User Control will be used on multiple pages, and all with the same result, however I just can't work out how to get that Navigate to work and then pass the parameter along. Any help would be appreciated..
Thanks.
If you are using standard WP template with one Frame set as Content of your Window then it should be possible to do it like this:
private void lstFoo_ItemClick(object sender, ItemClickEventArgs e)
{
(Window.Current.Content as Frame).Navigate(typeof(BarPage), e.ClickedItem);
}
Only look out with passing this parameter - if it's not serializable then when your app will be suspended then SuspensionManager will throw exception.
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