A few days ago bought two books of WP8.1 of forestry Administration teacher in the garden. After all, if you want to learn in depth, you still have to get a book to follow the predecessors.
Read today 1.4. Section 3-application example of a framework: Customize the Pop-up window section. In general, it's a function like Messagedialog, but with the ability to define buttons, text, and so on within the Dialog (such as color, font size). (Do not say contentdialog, that is, the Content dialog box can do most)
The principle is that a popup control is used as a pop-up container, and the child property of the popup is assigned as an instance of the popup window. In the book, The Popup class is a templated control named Mymessage,template contains a grid, and then a grid contains a Rectangle and a border,rectangle used as a translucent processing (equivalent to the background of a modal window in the Web Partially translucent gray-black), Border a stackpanel,stackpanel that contains the contents of a pop-up window. (Feeling this StackPanel is completely superfluous)
Effect (in 480*800):
Explanations of each layer:
The corresponding code:
1 <ControlTemplateTargetType= "Local:mymessage">2 <GridVerticalAlignment= "Stretch">3 <Rectanglex:name= "Backgroundrect"Grid.Row= "0"Fill= "Black"Opacity= "0.7"/>4 <Border5 VerticalAlignment= "Top" 6 borderthickness= "3" 7 BorderBrush= "Black">8 <StackPanelMargin= "0">9 <ContentPresenterx:name= "Body"/>Ten </StackPanel> One </Border> A </Grid> - </ControlTemplate>
View Code
Then, in order to hide the page's possible bottombar when the popup window is displayed, use Window.Current.Content as frame to get the current frame, get the page instance by traversing the visual tree of the current frame, and finally cache the display Bottombar state, hide the popup window, and then restore the Page's Bottombar state.
That is, to get the current frame, traverse the visual tree to get the Page is hidden for bottombar. (It took a long time to understand, has been thinking that the Popup does not need to be mounted on the page, then why to get Page-_-| | | )
Finally, I found a drawback of this way, because the width of the Popup is not bound to the width of the current window (WP can be seen with the width of the screen, because there is only one window), so only hard to set (in the example is to set the width of the templated control, as this can open the Popup). As a change in the screen orientation ...
A big cut on the right. This is not the same as Messagedialog said (; ´д ')
In addition, even if the screen is not selected, in the case of 1080p 6inch:
will also be vacated.
Well, can we just say that this is an inappropriate example? This is not to say that forestry administration teacher is not well written. (Because I can't figure out the application of the Framework-_-| | | )
The above is their own personal analysis, if there are deficiencies, please forestry administration teachers and the garden members pointed out.
Read the application example of the 1.4.3 framework for in-depth understanding of Windows Phone 8.1 UI Control Programming: Customizing Pop-up windows