仅在有键盘的情况下如何移动滚动条 [英] How move the scroll only when there are the keyboard

查看:167
本文介绍了仅在有键盘的情况下如何移动滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此功能来移动滚动条,但是当我没有键盘时会激活此功能,我只想在有键盘的情况下使用它,该如何解决呢?

I used this function to move my scroll, but this function is activated when I don't have a keyboard, I only want to use it when there is a keyboard, how can I solve this?

<Entry    Placeholder="entry" Focused="EntryKeyboardHandle_Focused"

void EntryKeyboardHandle_Focused(object sender, FocusEventArgs e)
        {
            Device.BeginInvokeOnMainThread(async () =>
            {
                    await Task.Delay(10);
                    await MainScroll.ScrollToAsync(0, 100, true);
            });
        }

我发现此线程 Xamarin表单检查键盘是否打开是否

我的输入名为"Entry",并且在我的代码中,Entry.Focused += keyboardService.KeyboardIsShown;后面,但是出现此错误.

I have my entry with name "Entry" and in my code behind Entry.Focused += keyboardService.KeyboardIsShown; but I get this error.

事件"IKeyboardService.KeyboardIsShown"只能显示在 + =或-=

The event 'IKeyboardService.KeyboardIsShown' can only appear on the left hand side of += or -=

推荐答案

根据发现的线程,可以尝试使用此代码.

ok accourding to the thread that you found you could try this code.

在构造器中添加此代码

private bool _keyboardIsOn;

cto(){
 // Initio
 keyboardService.KeyboardIsShown += (sender, e){ _keyboardIsOn = true; }
 keyboardService.KeyboardIsHidden += (sender, e){ _keyboardIsOn = false; }
}

否,您不能检查_keyboardIsOn并添加您的编码.

No you could check if _keyboardIsOn and add your coditions.

这篇关于仅在有键盘的情况下如何移动滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆