6

I'm currently use WPF and WIN8 table mode design some software.

There is some place need input some number use Textbox.

I use some way to finally show the Keyboard: http://brianlagunas.com/showing-windows-8-touch-keyboard-wpf/

But I found, sometimes the Keyboard will cover some item on the bottom or middle after it show up.

For example: I have 5 Textbox on the screen

<Grid>
  <TextBox HorizontalAlignment="Left" Margin="500,95,0,0"  Height="23" Width="120"/>
  <TextBox HorizontalAlignment="Left" Margin="500,295,0,0"  Height="23" Width="120"/>
  <TextBox HorizontalAlignment="Left" Margin="500,495,0,0"  Height="23" Width="120"/>
  <TextBox HorizontalAlignment="Left" Margin="500,695,0,0"  Height="23" Width="120"/>
  <TextBox HorizontalAlignment="Left" Margin="500,800,0,0"  Height="23" Width="120"/>
</Grid>

But now I found if the Keyboard get focus on some Textbox not on the top, Maybe on the middle or maybe on the bottom. The Keyboard will cover it. I even can't see what I am typing in.(Like the Picture)

enter image description here

So Is there any good way to fix it ? Thank you.

PS: I've try to drag the Keyboard, but Looks like it's not a good solution, because some Textbox on the middle, Keyboard will still cover which Textbox on the middle.

qakmak
  • 1,287
  • 9
  • 31
  • 62
  • What exactly are you hoping for here? You want to show the keyboard, but you don't want it to cover any of your TextBox, which are scattered across the full height of the screen. How can you have something cover the screen, but not cover the screen? – Glen Thomas Aug 06 '15 at 10:43
  • To me I thinking maybe some way just like windows 8 login screen. after the user password focus on the login password Textbox, the Keyboard auto display and also the Textbox position move to more top place, then I can see the Textbox and Keyboard together, that's you can see when you login win 8 Tablet. I think that's a only good way, But I don't know how let the all Textbox this way, because some textbox on the bottom, some of them on middle of screen, All need calculate, and another problem is the Keyboard need use other way to show up. WPF not support some API like Win8 tablet Keyboard. – qakmak Aug 07 '15 at 03:19

3 Answers3

3

The keyboard can be moved used by the user so that it is not covering. Its best to let the user handle the situation this way than try to re-engineer the Windows experience

Glen Thomas
  • 10,190
  • 5
  • 33
  • 65
  • As I said on the bottom of the question, even move the keyboard, it still cover the Textbox which is on the middle. – qakmak Aug 01 '15 at 17:04
  • Well you must redesign your layout. How can you expect the keyboard to not cover something? – Glen Thomas Aug 01 '15 at 17:19
  • 1
    But how? Can you at least give me some code example please? thank you. – qakmak Aug 02 '15 at 01:39
  • When the user enters a TextBox they will see the keyboard. Where the keyboard appears depends on the user. You cant know for sure where it will be. Its the Windows design. – Glen Thomas Aug 02 '15 at 01:50
3

to make this possible you have to do something similar to this.

1) your view must be scrollable (inside a scrollviewer)

2) textbox.BringIntoView() would normally work, but with the current solution you are using.. it won't be possible because the keyboard show is called after textbox.BringIntoView()...

See my post in this thread Show & hiding the Windows 8 on screen keyboard from WPF

It's a complete implementation of showing/hiding the win 8 keyboard and auto focus when the textbox is focused and you keep all the wpf touch functionality that you lose when you are using inkDisableHelper

Community
  • 1
  • 1
Guillaume
  • 180
  • 1
  • 8
  • you're demo only let us know how display keyboard, but not complete for the keyboard hide TextBox problem. – qakmak Oct 13 '15 at 15:17
  • Hi qakmak, textbox.BringIntoView() this element should be able to show the textbox but ur view must be scrollable otherwise the keyboard will hide the textbox. – Guillaume Oct 15 '15 at 13:17
  • you're not demo, I still not sure about that. you see: If the TextBox on the bottom, Is the scroll viewer still working? I think not. – qakmak Oct 17 '15 at 11:48
  • Hi, the keyboard auto resize your software (reduce the size of it) so your scrollviewer get a bigger range and this will make your textbox show. It work fine in my application with a windows surface. – Guillaume Oct 19 '15 at 19:15
0

The virtual keyboard is supposed to automatically move the focused TextBox into view when the keyboard is displayed.Microsoft says this behavior is automatic but can be overridden with EnsuredFocusedElementInView(example here)

I think this can be solved by adjusting the Y transition

     _offSet = 0;

        Windows.UI.ViewManagement.InputPane.GetForCurrentView().Showing += (s, args) =>
        {
            _offSet = (int)args.OccludedRect.Height;
            args.EnsuredFocusedElementInView = true;
            var trans = new TranslateTransform();
            trans.Y = -_offSet;
            this.RenderTransform = trans;
        };

        Windows.UI.ViewManagement.InputPane.GetForCurrentView().Hiding += (s, args) =>
        {
            var trans = new TranslateTransform();
            trans.Y = 0;
            this.RenderTransform = trans;
            args.EnsuredFocusedElementInView = false;
        };

inside the constructor.

Also you can take a look at

1)Tips and Tricks for C# Metro developers: Handling the virtual keyboard

2)Popup stays under virtual keyboard in stead of scrolling up with the bottom appbar

Rohit
  • 10,056
  • 7
  • 50
  • 82