ToastPrompt does not show up after navigating to page


Hi all,

in my app I go back from screen B to screen A and want to show a ToastPrompt directly after. When calling mytoastprompt.show() in the OnNavigatedTo function, the toast prompt does not show up. Using the Loaded event of the page does not work either. Calling the same code from a button OnClick, it works fine.

Could this be some issue with the Dispatcher.Invoke used when the page dom is not initiated yet?
I hope you can help me with this issue.

Thanks in advance

file attachments


crutkas wrote Oct 5, 2013 at 5:24 PM

Please include a repro project.

sibbl wrote Oct 6, 2013 at 10:19 AM

I found out that this is related to using page transitions. It seems that the OnNavigatedTo of the new page is being called when the old page is still visible. This results in the ToastPrompt being added to the old page, instead of the new one.

Pls find a example WP8 project attached.

If this won't be fixed, is there any way to work around this? I tried showing the toast prompt via the App.RootFrame.Navigated event handler, but this didn't work either. Do I need to set a timer which triggers the toast prompt when the transition animation should have been completed?

Thanks in advance and have a great sunday :)

crutkas wrote Oct 6, 2013 at 7:53 PM

Knew something else was going on cause I had a test just for this I thought. Will look into this.

crutkas wrote Oct 6, 2013 at 8:15 PM

So this is going to have me rip into the toolkit code as I'm not 100% why their code is causing this behavior.

Why are you leveraging the OnNav override? a lot of the visual DOM isn't created yet.

Easy quick fix solutions:

use Loaded event or wrap your toast in a dispatcher on the OnNavigatedTo
Dispatcher.BeginInvoke(() =>

                var toast = new ToastPrompt();
                toast.Message = "Hello worldx";
                toast.MillisecondsUntilHidden = 5000;


sibbl wrote Oct 8, 2013 at 7:40 PM

Loaded event + the Dispatcher did the trick. That was the only solution I couldn't think of... Thanks a lot for your help! :)

korbert wrote Dec 9, 2014 at 1:52 PM

I've also needed to await a little:

await Task.Delay(500);

crutkas wrote Dec 9, 2014 at 4:27 PM

korbert, would need to see what you're doing, if memory serves, this should work out of the box now without needing to wrap it in a dispatcher.