【发布时间】:2018-11-24 06:48:00
【问题描述】:
我知道 Android 上的解决方案
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
switch(keyCode){
case KeyEvent.KEYCODE_BACK:
// do something here
return true;
}
return super.onKeyDown(keyCode, event); }
但我不能在表单方面做到这一点。焦点是一个条目,因此键盘是可见的,当我按下硬件后退按钮(键盘消失)时,我想设置我的变量值。
已编辑:
bool _tapped;
LwTeszt.PropertyChanged += (s, e) =>
{
if (LwTeszt.SelectedItem != null)
{
EntryTeszt.Focus();
}
};
EntryTeszt.Unfocused += EntryTeszt_Unfocus;
private void EntryTeszt_Unfocus(object sender, FocusEventArgs e)
{
_tapped = true;
}
private void ViewCell_Tapped(object sender, EventArgs e)
{
if (_tapped)
{
EntryTeszt.Unfocus();
_tapped = false;
return;
}
EntryTeszt.Focus();
}
【问题讨论】:
标签: c# xamarin xamarin.forms keypress