I have my own technique.
I extract the hash code of the object and save it in the Dictionary , and the hash code as the key, and the object as the value of the pair.
Then I attach the hash code to UriQuery .
After that, I need to get the hash code that comes from Uri in the target view, and use it to query the source object from Dictionary .
Code example:
Parameter Repository Class:
public class Parameters { private static Dictionary<int, object> paramList = new Dictionary<int, object>(); public static void save(int hash, object value) { if (!paramList.ContainsKey(hash)) paramList.Add(hash, value); } public static object request(int hash) { return ((KeyValuePair<int, object>)paramList. Where(x => x.Key == hash).FirstOrDefault()).Value; } }
Caller Code:
UriQuery q = null; Customer customer = new Customer(); q = new UriQuery(); Parameters.save(customer.GetHashCode(), customer); q.Add("hash", customer.GetHashCode().ToString()); Uri viewUri = new Uri("MyView" + q.ToString(), UriKind.Relative); regionManager.RequestNavigate(region, viewUri);
Target View Code:
public partial class MyView : UserControl, INavigationAware {
What is it.
source share