Eva FP
Eva FP

Reputation: 775

Android toast for UWP

I would like to use a Toast (see image below) in an UWP project in the same way as Android. I know that UWP has a native control called ToastNotification but I think it's really showy (see the other attachment)...

It would be fantastic to find a similiar control or event to make it myself but I don't know where to start from, so any suggestion will be much appreciated.

Thanks in advance!

Android Toast Notification enter image description here

Upvotes: 0

Views: 720

Answers (3)

andyt_3185834
andyt_3185834

Reputation: 1

I have dug around myself for this, they say the simple "toast" ability Android has is not available with UWP, Toast class under UWP is actually Notification there. I was in fact correct myself from the beginning to roll it out myself. What I have problem myself is the window size and my own solution can't function at the very onset of OnNavigateTo(), it's a bit long winded so I'll give you the object players not the code entirety.

My XAML part of my home-brew solution is entirely enclosed within <Popup> ... </Popup>, not pretty, but I'll get it fixed. And SO is giving me grief about the code is improperly formatted so you don't get the entire coding, sorry.

The entry point of the code-behind isn't complex, see ThreadPoolTimer since SO keeps giving me grief on f'd code so sorry once more, what's remaining is Dispatcher.RunAsync(), do the thread work three times for fading in, let it show, and fade out. The RunAsync thing Android docs actually explained it in its equivalent OS quite clear, I'm not sure if Microsoft also said something along the line of Google's explanation but both UI on both OS is not thread-safe, I forgot this and got myself MarshallingException before I remember that.

RunAsync() takes an enum and a delegate to run. That is relaying the delegate to main thread to run.

Upvotes: 0

CodeNoob
CodeNoob

Reputation: 757

This question has been answered here. To sum it up you can use Coding4Fun toolkit and modify toast prompt.

Upvotes: 0

TableCreek
TableCreek

Reputation: 799

UWP apps don't provide this funtionality. The workaround I have made is to have a layer over each page which is transparent and is only visible for a short period of time when you activate it

Upvotes: 2

Related Questions