Solution to the problem that WP8 popup does not shift with the input method

Source: Internet
Author: User

We often need to implement this in WP. We will consider the effect of floating windows, but we will encounter a very embarrassing problem when developing Popup, because popup is not in the visualization tree of the main interface, when the position displayed in the popup is within the range displayed on the input method panel, the input method panel pops up and will not be directly overwritten by the input method due to the offset.

In the previous wp7.5, when the input method panel pops up, we can get the transform of the Root View to get the offset to offset our popup, but we didn't find this offset in WP8, there was no way to go through all kinds of UPS, and finally found a curve to save the country (under the RT framework ).

Input Method panel disappearance event

Void popupwindow_hiding (Windows. UI. viewmanagement. inputpane sender, windows. UI. viewmanagement. inputpanevisibilityeventargs ARGs)

{

// Clear the added offset when the input method panel disappears.

Animationmanager. Begin (animationfactory. Create (hosttransform, "translatey", 0, timespan. frommilliseconds (100 )));

}

 

Input Method panel pop-up event

Void popupwindow_showing (Windows. UI. viewmanagement. inputpane sender, windows. UI. viewmanagement. inputpanevisibilityeventargs ARGs)

{

If (isshow)

{

// Triggered when the showing Input Method panel starts to pop up

// Start recording the coordinates of window. Current. content to the screen

VaR last = Window. Current. content. transformtovisual (null). transformpoint (new windows. Foundation. Point (0, 0 ));

Eventhandler <Object> handler = NULL; // only the inputpane display event can barely use the layoutupdated event...

// Register the layoutupdated event and obtain the coordinates of window. Current. content 0, 0, relative to the screen.

(Window. Current. content as frameworkelement). layoutupdated + = handler = (S, e) =>

{

// When the 0,ing from 0 to 0 to screen current is not equal to last, it is considered that inputpane is enabled successfully ^_^

VaR current = Window. Current. content. transformtovisual (null). transformpoint (new windows. Foundation. Point (0, 0 ));

If (current! = Last) // It is found that the coordinates before the removal are not equal. It is considered that an offset has occurred and an offset is added to the current view.

{

Current. Y = current. Y-last. Y-inputoffset;

(Window. Current. content as frameworkelement). layoutupdated-= handler;

(Hosttransform as windows. UI. XAML. Media. compositetransform). translatey = current. Y;

}

};

}

}

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.