Search code examples
c#xamluwpwindows-10-mobile

Keyboard Behavior on ContentDialog with Windows 10 Mobile (UWP)


When I open a content dialog programmatically, the first objet catching the focus and the content dialog's shape was distorted.

Are any way available show the keyboard on the content dialog without distort the general shape ?

Thanks.

Screenshot:

Keyboard opened on content dialog.


Solution

  • When the keyboard shows, the ContentDialog will adjust its height automatically. And this will cause the change of ContentDialog's Content's height. So when the keyboard shows, the Content's height becomes small and the rest of the Content is blocked.

    If you want the keyboard shows without distorting the general shape, you can set the MinHeight property of ContentDialog. For example, you can give ContentDialog a large MinHeight like "500"

    <ContentDialog x:Name="contentDialog" MinHeight="500" />
    

    Or

    contentDialog.MinHeight = 500;
    

    After this, when the ContentDialog adjust its height, its height will be 500 at least and if this height is large enough, it will not distort the general shape. You may set the MinHeight equal to ContentDialog's default height to make sure it's large enough.