Read the application example of the 1.4.3 framework of Windows Phone 8.1 UI control programming: Custom pop-up window, ui control

Source: Internet
Author: User

Read the application example of the 1.4.3 framework of Windows Phone 8.1 UI control programming: Custom pop-up window, ui control

I bought two WP8.1 books from Mr Lin Zheng in the garden the other day. After all, if you want to learn more deeply, you still have to get this book to follow your predecessors.

Today, I read section 1.4.3-application example of the framework: Custom pop-up window. In general, it is to get something like MessageDialog, but also to have the ability to define buttons, text, and so on in the Dialog (such as color, font size ). (Not to mention ContentDialog, that is, the content dialog box can be mostly implemented)

A Popup control is used as the container for the pop-up window. The Child attribute of Popup is assigned to the pop-up window instance. In the book, the pop-up window class is a templated control named MyMessage. The Template contains a Grid, and the Grid contains a Rectangle and a Border, rectangle is used for translucent processing (equivalent to the translucent gray-black background of the modal window in the Web). Border has a StackPanel, which stores the content of the pop-up window. (It seems that this StackPanel is completely redundant)

Effect (in 480*800 ):

Explanation of each layer:

Code:

1 <ControlTemplate TargetType = "local: MyMessage"> 2 <Grid verticalignment = "Stretch"> 3 <Rectangle x: Name = "backgroundRect" Grid. row = "0" Fill = "Black" Opacity = "0.7"/> 4 <Border 5 verticalignment = "Top" 6 BorderThickness = "3" 7 BorderBrush = "Black"> 8 <StackPanel Margin = "0"> 9 <ContentPresenter x: name = "body"/> 10 </StackPanel> 11 </Border> 12 </Grid> 13 </ControlTemplate>View Code

To hide the BottomBar that may exist in the Page when the pop-up Window is displayed, use Window. current. content as Frame gets the current Frame, retrieves the Page instance by traversing the visible tree of the current Frame, and caches the BottomBar status when it is displayed to hide the pop-up window, restore the BottomBar status of the Page.

That is to say, retrieving the current frame and traversing the visual tree to retrieve the Page are all for BottomBar hiding. (It took a long time to figure out why the Popup does not need to be mounted to the Page)

 

Finally, one disadvantage I found in this method is that the width of the Popup cannot be bound to the width of the current window (WP can be regarded as the width of the screen, because there is only one window ), therefore, you can only set it hard (in this example, set the width of the templated control, because it can support Popup ). So, when the screen orientation changes...

The right side is empty ...... This is different from MessageDialog (; 'alipay ')

In addition, even if no screen is selected, in the case of 1080 p 6inch:

It will also be empty.

 

Er, can this example be inappropriate? This is not to say that Mr Lin has not written well. (Because I cannot figure out the framework application-_-|)

The above is my personal analysis. If there are any deficiencies, please point out it to Teacher Lin Zheng and all of you in the garden.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.