Windows 8 keyboard Push customization processing

Source: Internet
Author: User

In a Windows 8 application, Input Panel pops up when the TextBox control gets the focus, and if the TextBox control is in the lower half of the page, the system pushes the page up the textbox is not covered by the Input Panel, but when the textbox is in the Flipview control , the system does not push the page, so the input box is covered by the Input Panel. The specific reason is not clear, do not know is not a system bug.

When the Input Panel pops up, the action on the page can be handled by listening to the inputpane showing and hiding events, since when the textbox is in the Flipview control, the system does not have a good processing page to push, Then the developer can handle the push by listening to Inputpane events.

An instance code for Windows 8 responding to the appearance of the On-Screen Keyboard sample describes what to do if the listener handles Inputpane, reference this instance to the T in Flipview The Extbox control is an example and simplifies processing of the instance code.

The inputpanehelper in the instance is the encapsulation of Inputpane event handling, used directly, Inputpanehelper code as follows:

Using System;   
Using System.Collections.Generic;   
Using Windows.UI.ViewManagement;   
Using Windows.UI.Xaml;   
Using Windows.foundation;   
       
Using Windows.UI.Xaml.Media.Animation; Namespace Huizhang212.keyboard {public delegate void Inputpaneshowinghandler (object sender, Inputpanevisibili   
    Tyeventargs e);   
    public delegate void Inputpanehidinghandler (Inputpane input, Inputpanevisibilityeventargs e);   
        public class Inputpanehelper {private dictionary<uielement, inputpaneshowinghandler> Handlermap;   
        Private UIElement lastfocusedelement = null;   
       
        Private Inputpanehidinghandler hidinghandlerdelegate = null; Public Inputpanehelper () {handlermap = new dictionary<uielement, inputpaneshowinghandler>   
        (); } public void Subscribetokeyboard (bool subscribe) {Inputpane input = Inputpa Ne.   
 Getforcurrentview ();           if (subscribe) {input.   
                showing + = Showinghandler; Input.   
            hiding + = Hidinghandler; else {input.   
                Showing-= Showinghandler; Input.   
            hiding-= Hidinghandler;   
        } public void Addshowinghandler (uielement element, Inputpaneshowinghandler handler) {if (Handlermap.containskey (element)) {throw new System.Exception (   
            "A handler is already registered!");   
                else {Handlermap.add (element, handler); Element.   
                GotFocus + = Gotfocushandler; Element.   
            LostFocus + = Lostfocushandler;   
            } private void Gotfocushandler (object sender, RoutedEventArgs e) {   
   Lastfocusedelement = (UIElement) sender;     } private void Lostfocushandler (object sender, RoutedEventArgs e) {if   
            (Lastfocusedelement = = (UIElement) sender)   
            {lastfocusedelement = null;   
        } private void Showinghandler (Inputpane sender, Inputpanevisibilityeventargs e) {if (lastfocusedelement!= null && handlermap.count > 0) {h  

 
            Andlermap[lastfocusedelement] (lastfocusedelement, E);   
        } lastfocusedelement = null;   
            private void Hidinghandler (Inputpane sender, Inputpanevisibilityeventargs e) {   
            if (hidinghandlerdelegate!= null) {hidinghandlerdelegate (sender, E);   
        } lastfocusedelement = null;   
 } public void Sethidinghandler (Inputpanehidinghandler handler)       {this.hidinghandlerdelegate = handler; public void Removeshowinghandler (UIElement element) {Handlermap.remove (ele   
            ment); Element.   
            GotFocus-= Gotfocushandler; Element.   
        LostFocus-= Lostfocushandler; }   
    }   
}

Related Article

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.