如何处理"Don't ask me again" Windows Phone



所以我使用Silverlight工具包样本来帮助我为我正在构建的Windows Phone 8应用程序构建一个CustomMessageBox。当用户点击应用程序中的某个按钮时,我想告诉用户,在这个按钮工作之前,他们首先需要启动其他东西。

在消息框中,我将向用户解释这一点,但我想添加一个"Don't Show me this again"复选框。问题是我不确定如何处理messageBox中的"不要再显示我"复选框。Dissmissed事件。工具包样本遗漏了这一部分,我似乎无法在互联网上找到对我来说足够清楚的信息。

提前感谢任何帮助,我是新的编码和依赖样本很多,让我去。

messageBox.Dismissed += (s1, e1) =>
            {
                switch (e1.Result)
                {
                    case CustomMessageBoxResult.LeftButton:
                        // Do ask me again.
                        break;
                    case CustomMessageBoxResult.None:
                        if ((bool)checkbox.IsChecked)
                        {
                            // Do not ask me again.
                        }
                        else
                        {
                            // Ask again later.
                        }
                        break;
                    default:
                        break;
                }
            };
        messageBox.Show();

如果用户选择不再提示他,您可以将他的选择保存在像这样的隔离存储设置中。

System.IO.IsolatedStorage.IsolatedStorageSettings settings = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings;
if(!settings.Contains("DontAskMeAgain"))
   settings.Add("DontAskMeAgain", "1");
else
   settings["DontAskMeAgain"] = "1";

在用CustomMessageBox提示用户之前,首先检查是否设置了DontAskMeAgain

if(!(settings.Contains("DontAskMeAgain") && settings["DontAskMeAgain"]=="1"))
   //CustomMessageBox.show();
else
   //dont show

最新更新