Windows phone 7 获取wp7发布次数评级的消息框

Windows phone 7 获取wp7发布次数评级的消息框,windows-phone-7,Windows Phone 7,最近我一直在尝试添加一个消息框,该消息框应该在某个时间间隔内弹出(例如应用程序启动次数)。此消息框也可以永久隐藏以防弹出 以下代码块可以放入任何现有应用程序中,并有助于提供上述功能: 在.xaml页面中, public partial class MainPage : PhoneApplicationPage { private static bool PerformedRatingPromptCheck = false; // Constructor public M

最近我一直在尝试添加一个消息框,该消息框应该在某个时间间隔内弹出(例如应用程序启动次数)。此消息框也可以永久隐藏以防弹出

以下代码块可以放入任何现有应用程序中,并有助于提供上述功能:

在.xaml页面中,

public partial class MainPage : PhoneApplicationPage
{
    private static bool PerformedRatingPromptCheck = false;
    // Constructor

    public MainPage()
    {
        InitializeComponent();
    }
}

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
    {
        if (!PerformedRatingPromptCheck)
        {
            PerformedRatingPromptCheck = true;

            int numAppLaunches = 0;
            IsolatedStorageSettings.ApplicationSettings.TryGetValue<int>("Rating_numAppLaunches", out numAppLaunches);

            int numNextRatingPrompt = 0;
            if (!IsolatedStorageSettings.ApplicationSettings.TryGetValue<int>("Rating_numNextRatingPrompt", out numNextRatingPrompt))
            {
                numNextRatingPrompt = 3;
            }

            if (numAppLaunches >= numNextRatingPrompt)
            {
                IsolatedStorageSettings.ApplicationSettings["Rating_numNextRatingPrompt"] = numNextRatingPrompt * 2;

                NotificationBox.ShowAgain("Enjoying the app?",
                        "Would you like to rate this app now, support us?",
                        "Ask me later",
                        false,
                        Surpressed => { },
                        "Rating_MsgPrompt",
                        new NotificationBoxCommand("yes", () => { new MarketplaceReviewTask().Show(); }),
                        new NotificationBoxCommand("no", () => { }));
            }

            IsolatedStorageSettings.ApplicationSettings["Rating_numAppLaunches"] = numAppLaunches + 1;
        }
    }
**//别忘了在xaml页面上添加此代码**
在.xaml.cs页面中,

public partial class MainPage : PhoneApplicationPage
{
    private static bool PerformedRatingPromptCheck = false;
    // Constructor

    public MainPage()
    {
        InitializeComponent();
    }
}

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
    {
        if (!PerformedRatingPromptCheck)
        {
            PerformedRatingPromptCheck = true;

            int numAppLaunches = 0;
            IsolatedStorageSettings.ApplicationSettings.TryGetValue<int>("Rating_numAppLaunches", out numAppLaunches);

            int numNextRatingPrompt = 0;
            if (!IsolatedStorageSettings.ApplicationSettings.TryGetValue<int>("Rating_numNextRatingPrompt", out numNextRatingPrompt))
            {
                numNextRatingPrompt = 3;
            }

            if (numAppLaunches >= numNextRatingPrompt)
            {
                IsolatedStorageSettings.ApplicationSettings["Rating_numNextRatingPrompt"] = numNextRatingPrompt * 2;

                NotificationBox.ShowAgain("Enjoying the app?",
                        "Would you like to rate this app now, support us?",
                        "Ask me later",
                        false,
                        Surpressed => { },
                        "Rating_MsgPrompt",
                        new NotificationBoxCommand("yes", () => { new MarketplaceReviewTask().Show(); }),
                        new NotificationBoxCommand("no", () => { }));
            }

            IsolatedStorageSettings.ApplicationSettings["Rating_numAppLaunches"] = numAppLaunches + 1;
        }
    }
public部分类主页:PhoneApplicationPage
{
私有静态布尔执行PromptCheck=false;
//建造师
公共主页()
{
初始化组件();
}
}
已加载专用void PhoneApplicationPage_(对象发送方,路由目标)
{
如果(!执行提示检查)
{
PerformedRatingPromptCheck=真;
int numaplunches=0;
隔离存储设置.应用程序设置.TryGetValue(“额定值”\u numAppLaunches“,out numAppLaunches);
int numextratingprompt=0;
if(!IsolatedStorageSettings.ApplicationSettings.TryGetValue(“额定值”\u NumExtratingPrompt“,out NumExtratingPrompt))
{
numExtratingPrompt=3;
}
if(numaplunches>=numextratingprompt)
{
隔离存储设置。应用程序设置[“额定值”\u numextratingprompt”]=numextratingprompt*2;
NotificationBox.showreach(“享受应用程序?”,
“是否要立即对此应用进行评分,是否支持我们?”,
“稍后再问我”,
假,,
suppressed=>{},
“评级提示”,
new NotificationBoxCommand(“yes”,()=>{new MarketplaceReviewTask().Show();}),
新的NotificationBoxCommand(“no”,()=>{});
}
隔离存储设置。应用程序设置[“Rating_NumapPlaunces”]=NumapPlaunces+1;
}
}
来源-