I have an issue with the CustomMessageBox from the WP Toolkit. Currently, I have code that launches a prompt for an app rating on every two clicks of a button.
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++;
All options seem to work fine except those that actually launch the MarketplaceReviewTask. The task launches correctly, but on resuming the app I'm hitting a 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.Transition.OnCompleted(Object sender, EventArgs e) at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)}
How can I fix this? Changing to the MessagePrompt in the Coding4Fun Toolkit is a LAST resort.