Windows phone 7 重新使用另一页上的列表
我有个问题。我创建了如下列表:Windows phone 7 重新使用另一页上的列表,windows-phone-7,windows-phone-8,Windows Phone 7,Windows Phone 8,我有个问题。我创建了如下列表: _Results.Add(new Result(_currentQuestion.Question, choice, _currentQuestion.ImagePath)); public static List<T> _Result =new List<T>(); LstResult.Add("Value"); 现在我想在我的应用程序的另一个页面上重用这个列表。 如何实现这一点?步骤1:- 在第一页中,您必须将列表声明为静态,如下
_Results.Add(new Result(_currentQuestion.Question, choice, _currentQuestion.ImagePath));
public static List<T> _Result =new List<T>();
LstResult.Add("Value");
现在我想在我的应用程序的另一个页面上重用这个列表。
如何实现这一点?步骤1:-
在第一页中,您必须将列表声明为静态,如下所示:
_Results.Add(new Result(_currentQuestion.Question, choice, _currentQuestion.ImagePath));
public static List<T> _Result =new List<T>();
LstResult.Add("Value");
步骤2:-
在另一个页面中,您要访问此列表,请首先像下面这样声明列表
public List<T> _result =new List<T>()
public List\u result=new List()
\u result=ClassName.\u result代码>-这里的类名将是您的第一页类名
这里List
-T表示您的列表类型如果您需要持久化\u Results
对象的状态,我建议您创建一个静态容器类
,并对其执行任何操作。该状态将在整个应用程序中保持
public static class _cont
{
public static List<Result> _Result;
}
公共静态类\u cont
{
公共静态列表_结果;
}
但最简单、更干净的方法应该是将\u结果
存储在隔离存储
中,并在需要时检索它。您可以使用async
方法来加载/存储\u结果
对象。在您的命名空间中有一个如下所示的类
namespace xxx
{
public static class Result
{
private static List<string> lstResult;
public static List<string> LstResult
{
get { return lstResult; }
set { lstResult= value; }
}
}
}
尝试使用上述静态变量概念将有助于您的快速反应,但不幸的是,我在\u Result=
下看到红线(找不到类型或名称空间)。我做错了什么?我应该用类名替换\u result
。\u result
,对吗?我确信我的答案是正确的,但你在程序中的某个地方犯了错误