仅在有键盘的情况下如何移动滚动条
我使用此功能来移动滚动条,但是当我没有键盘时会激活此功能,我只想在有键盘的情况下使用它,该如何解决呢?
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.