One of the limitations that my InputAwarePanel had was that even though it resized available space properly when the InputPane is shown, it didn’t actually keep the TextBox in view when that happened. Even though this sounds like a simple task, I quickly found out that it was quite the opposite. I’ll go over some of the issues I encountered, point out unresolved limitations, and show a small demo of it in action. Along with this little improvement, I’ve also made the source code available on CodePlex for anyone to check out and improve so please check it out and report any bugs you may find.
The MaterialCODEPLEX – view source + contribute
NUGET – download and use
The InputPanelAware panel works the same as before. What’s different is now you don’t have to manually scroll TextBox in focus into view. Whenever a TextBox is focused and it’s in a ScrollViewer, the ScrollViewer will scroll it into view appropriately. This feature isn’t limited strictly to only TextBoxes. It also works with RichTextBox and PasswordBox but it doesn’t support scrolling to cursor position whereas the TextBox does. I’ve also intentionally omitted the AutoSuggestBox since it automatically handles scrolling into view out of the box.
Here’s a video of it in action:
What Doesn’t Work
Like I mentioned before, only the TextBox control supports scrolling to cursor. This is helpful when the text input control is taller than the viewable area of the ScrollViewer. If the text input control is in view but extends below that viewable area, there’s a possibly that the cursor is still out view. The cursor is what the user is focused on and should be what’s brought into view. We can get the visual position of the cursor using TextBox’s GetRectFromCharacterIndex method and accomplish this. Unfortunately, the other text input controls do not so I can scroll into view the entire control and depend on the user to scroll to whatever they want to see.
In this current release, there’s no support for horizontal scrolling into view yet. I wanted to get this out since someone on MSDN forums was looking for a solution at he time of writing this.
I’ve made the source code for this available on CodePlex for anyone to check out. The link can be found above. I’ll be trying to document this as much as possible there so anyone can easily use this. If you notice any bugs or issues, I’d be grateful if you bring it up there so I can improve this as much as I can. Of course, suggestions for improvements and contribution for fixes are always welcomed.