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;
}
};
}
}