Original: uwp-message hint (imitation Android)
In the Message prompt box (a) in the UWP, there are some common message-prompt boxes that require the user to intervene actively, and then they want to talk about some message-prompt boxes that do not require the user to intervene actively. The effect is like a double-exit cue box.
It's easier to talk about it by system toast notifications (and Android toast is a different amount, more like Android notification), and in this case there's no code here, it's clear on MSDN (QuickStart: Sending Toast Notification), something to be aware of as an in-app message popup box, should not be bands (there is a special need seems to be OK), however, the toast notification will leave a notification in the system Notification Center content, The dismissed event of the Toastnotification instance needs to be monitored and passed ToastNotificationManager.History.Remove (Toasttag) Implementation does not leave traces in the system Notification Center after the toast notification disappears. Another problem is this way on the PC if the app is not running full-screen, pop-up in the lower right corner of the person feel that some are not very friendly, or the tablet (and the tablet mode) split-screen operation (and the current app on the left side) from the bottom right to pop a hint users will be confused.
Again, since speaking of Android Toast, it's a good thing to do this in the UWP to implement a message prompt similar to an android toast. As in the previous article, I still through the popup+usercontrol way to achieve, of course, the way of implementation is also more, such as Adi Wang's blog: The implementation of the modal frame progress indicator
Adnroid most of the mobile phones are in the screen at the bottom of a dot with a point of transparency of the black area to display the hint content, usually 2S fade out of the disappearance, generally this is the toast in adnroid, the description is not clear, look at the picture bar.
When implemented in the UWP, write a layout in UserControl and then write a fade-out animation that delays 2s execution. The code is roughly:
Notifypopup.xaml:
<UserControl.Resources> <storyboard x:name= "Sbout" > <doubleanimationusingkeyframes Story Board. Targetname= "Maingrid" storyboard.targetproperty= "Opacity" be Gintime= "0:0:0" > <splinedoublekeyframe keytime= "00:00:00.00" value= "1"/> <splin Edoublekeyframe keytime= "00:00:00.400" value= "0.0"/> </DoubleAnimationUsingKeyFrames> </sto ryboard> </UserControl.Resources> <grid x:name= "Maingrid" > <Grid.RowDefinitions> <rowdefinition height= "*"/> <rowdefinition height= "*"/> </Grid.RowDefinitions> <border grid.row= "1" background= "#aa000000" horizontalalignment= "Center" verticalalignment= "Top" margin= "0,50" P adding= "20,15" > <textblock x:name= "tbnotify" textwrapping= "Wrap" foreground= "#daffffff"/> </ Border> </grid>
NotifyPopup.xaml.cs:
Public sealed partial class Notifypopup:usercontrol {private Popup m_popup; private string m_textblockcontent; Private TimeSpan M_showtime; Private Notifypopup () {this. InitializeComponent (); M_popup = new Popup (); This. Width = Window.Current.Bounds.Width; This. Height = Window.Current.Bounds.Height; M_popup.child = this; This. Loaded + = notifypopup_loaded; This. Unloaded + = notifypopup_unloaded; Public Notifypopup (String content, TimeSpan ShowTime): this () {this.m_textblockcontent = cont Ent This.m_showtime = ShowTime; Public Notifypopup (String content): This (content, Timespan.fromseconds (2)) {} public void Show () {This.m_Popup.IsOpen = true; private void Notifypopup_loaded (object sender, RoutedEventArgs e) {this.tbNotify.Text =M_textblockcontent; This.sbOut.BeginTime = This.m_showtime; This.sbOut.Begin (); this.sbOut.Completed + = sbout_completed; Window.Current.SizeChanged + = current_sizechanged; } private void Sbout_completed (object sender, Object e) {This.m_Popup.IsOpen = false; private void Current_sizechanged (object sender, Windows.UI.Core.WindowSizeChangedEventArgs e) { This. Width = E.size.width; This. Height = E.size.height; private void Notifypopup_unloaded (object sender, RoutedEventArgs e) {Window.Current.SizeChange D-= current_sizechanged; } }
Then put a button in the page, click to trigger the pop-up of the prompt box:
Notifypopup notifypopup = new Notifypopup ("Cue something!"); Notifypopup.show ();
Final effect
Of course, you can add some control in the UserControl, with the writing animation to make the format of various prompts.
The common Message prompt box in the UWP is almost finished, the last question, the attentive little partner will find that My side to the UserControl specified width is Window.Current.Bounds.Width and Window.Current.Bounds.Height, this seems to be no problem, but it is important to note that if the contents of the box below, modify the above code, so that it in the AP p at the bottom of the pop-up, Notifypopup.xaml make the following changes:
PC and some entity navigation bar of the phone is still normal, but in the virtual navigation bar of the phone and virtual navigation bar in the reality of the situation so the window is not normal (the example here shows only one line
About the adaptation of this screen, next time chat ... Move the bricks.
Copied from: http://www.cnblogs.com/helloblog/p/5225306.html
uwp-message hint (imitation Android)