在Windows Phone 7中,将值从一种形式传递到另一种形式可以通过以下方法实现:
NavigationService.Navigate(new Uri("/TargetPage.xaml?param=example", UriKind.Relative));
在目标页面中,可以使用以下代码从查询字符串中获取值:
string paramValue = "";
NavigationContext.QueryString.TryGetValue("param", out paramValue);
PhoneApplicationService.Current.State["param"] = "example";
在目标页面中,可以从PhoneApplicationService中获取该值:
string paramValue = (string)PhoneApplicationService.Current.State["param"];
public static class Globals
{
public static string ParamValue { get; set; }
}
在源页面中,可以将值存储在静态变量中:
Globals.ParamValue = "example";
在目标页面中,可以从静态变量中获取该值:
string paramValue = Globals.ParamValue;
总之,在Windows Phone 7中,可以使用多种方法将值从一种形式传递到另一种形式。具体选择哪种方法取决于您的应用程序需求和架构。
领取专属 10元无门槛券
手把手带您无忧上云