简体   繁体   中英

C# UWP sending List to the next page

I have a little problem. I have to make an app in UWP, and I have to send an item to other page while staying on the same page. And I have no idea how to acomplish that. I have tried different things, but I always ended up on transfering my List to the page, and also transfering view to thta page. I would really apreciate your help.

If you want to pass parameters when navigating to the page, you can use the following method:

If you don't use the Frame control for navigation

var frame = Window.Current.Content as Frame;
frame.Navigate(typeof(MyPage), myItem);

If you use the Frame control for navigation

frame.Navigate(typeof(MyPage), myItem);

If you are not passing parameters through navigation, you are passing data to another page in the current page. Then we can achieve this in another way.

Suppose we want to modify the data of the parentPage in the childPage, we can add a static object when navigating to the parentPage.

public static MainPage Current;
public MainPage()
{
    this.InitializeComponent();
    Current = this;
}

public void doSomething(string param)
{
    // do something...
}

In other pages, we can make some modifications by accessing this object:

MainPage.Current.doSomething("Hello");

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM