WP Toolkit の CustomMessageBox に問題があります。現在、ボタンを 2 回クリックするたびにアプリの評価を求めるプロンプトを起動するコードがあります。
Dispatcher.BeginInvoke(() =>
{
if (rtcount == 2 && (AppSettings.ShowAgainSetting == true))
{
CheckBox checkBox = new CheckBox()
{
Content = "Do not ask me again",
Margin = new Thickness(0, 14, 0, -2)
};
TiltEffect.SetIsTiltEnabled(checkBox, true);
CustomMessageBox messageBox = new CustomMessageBox()
{
Caption = "Would you like to rate and review this application?",
Message =
"Thank you for using my app."
+ Environment.NewLine + Environment.NewLine
+ "If you've been enjoying the app we'd love if you could leave us a rating in the Store. Would you mind spending a couple of seconds to rate (and/or) review this application?",
Content = checkBox,
LeftButtonContent = "ok",
RightButtonContent = "not now",
};
messageBox.Dismissed += (s1, e1) =>
{
switch (e1.Result)
{
case CustomMessageBoxResult.LeftButton:
if ((bool)checkBox.IsChecked)
{
MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();
marketplaceReviewTask.Show();
AppSettings.ShowAgainSetting = false;
}
else
{
MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();
marketplaceReviewTask.Show();
}
break;
case CustomMessageBoxResult.RightButton:
if ((bool)checkBox.IsChecked)
{
AppSettings.ShowAgainSetting = false;
}
else
{
}
break;
case CustomMessageBoxResult.None:
if ((bool)checkBox.IsChecked)
{
AppSettings.ShowAgainSetting = false;
}
else
{
}
break;
default:
break;
}
};
messageBox.Show();
rtcount = 0;
}
});
rtcount++;
実際に MarketplaceReviewTask を起動するオプションを除いて、すべてのオプションが正常に機能しているようです。タスクは正しく起動しますが、アプリを再開すると NullReferenceException が発生します。
{System.NullReferenceException: NullReferenceException at Microsoft.Phone.Controls.CustomMessageBox.ClosePopup(Boolean restoreOriginalValues) at Microsoft.Phone.Controls.CustomMessageBox.<>c_ DisplayClass4.b _1(Object s, EventArgs e) at Microsoft.Phone.Controls. MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex、文字列 eventName)}
どうすればこれを修正できますか? Coding4Fun ツールキットの MessagePrompt への変更は最後の手段です。