Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 保存布尔状态的XML。(折叠并展开画布)_C#_Xml_Visual Studio 2010_Windows Phone 7 - Fatal编程技术网

C# 保存布尔状态的XML。(折叠并展开画布)

C# 保存布尔状态的XML。(折叠并展开画布),c#,xml,visual-studio-2010,windows-phone-7,C#,Xml,Visual Studio 2010,Windows Phone 7,课程背景: 我正在为WindowsPhone7开发一个应用程序,你可以在其中输入你一周的日常活动和营养计划,这样人们可以在去健身房时得到提醒 每天都有一个小小的列表,上面列出了当天的锻炼重复次数和锻炼计划。然而,如果他们那天没有训练,也就是说这是“休息日”,他们按下“休息日”按钮,屏幕上就会出现一块画布,上面写着“休息日” 问题是,我让应用程序使用xml保存画布的关闭或打开状态,这样当用户返回到该页面或回到应用程序时,画布应该是他们离开画布的方式 我目前拥有的代码是: 在程序加载时:检查上次使用

课程背景:

我正在为WindowsPhone7开发一个应用程序,你可以在其中输入你一周的日常活动和营养计划,这样人们可以在去健身房时得到提醒

每天都有一个小小的列表,上面列出了当天的锻炼重复次数和锻炼计划。然而,如果他们那天没有训练,也就是说这是“休息日”,他们按下“休息日”按钮,屏幕上就会出现一块画布,上面写着“休息日”

问题是,我让应用程序使用xml保存画布的关闭或打开状态,这样当用户返回到该页面或回到应用程序时,画布应该是他们离开画布的方式

我目前拥有的代码是:

在程序加载时:检查上次使用程序时,用户的休息日画布是向上(true)还是向下(false)

星期一的休息按钮:这会把画布放上去(隐藏列表)

该程序似乎根本不保存画布的状态,当我按下画布折叠或启动时,程序崩溃


你有什么想法吗?我真的很难找到解决方法。

您正在写入设置,但从未读取设置。保持键名不变,其中包含true或false<代码>IsolatedStorageSettings.ApplicationSettings.Add(“monrest”,true)
bool isMonRest=IsolatedStorageSettings.ApplicationSettings[“monrest”]哦,我明白了。您刚才提到的行“bool isMonRest=IsolatedStorageSettings.ApplicationSettings[“monrest”];“我需要在它假定的某个地方添加它,或者我需要更改我当前拥有的一行吗?我不知道您拥有什么。您没有发布用于阅读的代码,只保存了一个名为“true”的ApplicationSettings键、一个名为“false”的键和一个xml文件。但是没有阅读。顺便说一句,您可以在应用程序设置中添加更多内容,而不仅仅是布尔或字符串。您可以执行
ApplicationSettings[“listOfTasks”]=GenerateMonertData()
保存并
将savedData=ApplicationSettings[“listOfTasks”]列为列表读取。不要管XML,它对于简单的任务来说太复杂了。好的,非常感谢,我会考虑在这项工作中使用其他东西
bool searchValueMon;
if (monRest == true)
{
    canMon.Visibility = Visibility.Collapsed;
    mondayReadData();
    IsolatedStorageSettings.ApplicationSettings.Remove("true");
    IsolatedStorageSettings.ApplicationSettings.Save();
}

else

{
    canMon.Visibility = Visibility.Visible;
    IsolatedStorageSettings.ApplicationSettings.Remove("false");
    IsolatedStorageSettings.ApplicationSettings.Save();
}
       canMon.Visibility = Visibility.Visible;
       monRest = false;

        IsolatedStorageSettings.ApplicationSettings.Add("false", monRest);


        // Write to the Isolated Storage
        XmlWriterSettings x_W_Settings = new XmlWriterSettings();
        x_W_Settings.Indent = true;

        using (IsolatedStorageFile ISF = IsolatedStorageFile.GetUserStoreForApplication())
        {
            using (IsolatedStorageFileStream stream = ISF.OpenFile("MonRest.xml", FileMode.Create))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(List<Rest>));
                using (XmlWriter xmlWriter = XmlWriter.Create(stream, x_W_Settings))
                {
                    serializer.Serialize(xmlWriter, GenerateMonRestData());
                }
            }
        }

        IsolatedStorageSettings.ApplicationSettings.Remove(Convert.ToString(monRest));
        IsolatedStorageSettings.ApplicationSettings.Save();
   private void btnMonEx_Click(object sender, RoutedEventArgs e)
    {
        canMon.Visibility = Visibility.Collapsed;
        //monRest = true;

        // IsolatedStorageSettings.ApplicationSettings.Remove("false");
        IsolatedStorageSettings.ApplicationSettings.Add("true", monRest);

        //IsolatedStorageSettings.ApplicationSettings.Save();

        mondayReadData();


       // IsolatedStorageSettings.ApplicationSettings.Remove(Convert.ToString(monRest));
        IsolatedStorageSettings.ApplicationSettings.Save();

    }