【发布时间】:2019-09-12 21:15:52
【问题描述】:
我在 Xamain 表单中使用网格,我想在选择事件上调用我认为做这个词 wok 的键盘。
我正在使用插件对话工具包来显示数字条目,但我的问题是键盘仅在具有焦点时才显示在文本框上我如何强制键盘出现以便用户不必点击进入领域。
new Entry()
{
Keyboard = Keyboard.Numeric
};
var resultQty = await Plugin.DialogKit.CrossDiaglogKit.Current.GetInputTextAsync("Test", $"Please goto Bin {item.BinName} , and enter the visible stock of the item." + item.Name, null, Keyboard.Numeric);
Dialog kit 中的代码显示它试图将焦点放在输入字段上。
<ContentView.Content>
<StackLayout Padding="10" BackgroundColor="White" VerticalOptions="CenterAndExpand" Margin="25">
<Label FontAttributes="Bold" FontSize="Large" Text="{Binding Title}"/>
<Label FontSize="Large" Text="{Binding Message}"/>
<Entry x:Name="txtInput" Keyboard="{Binding Keyboard}"/>
<StackLayout Margin="10" Orientation="Horizontal">
<Button Text="{Binding OK}" Clicked="Confirm_Clicked" HorizontalOptions="FillAndExpand"/>
<Button Text="{Binding Cancel}" Clicked="Cancel_Clicked" HorizontalOptions="FillAndExpand"/>
</StackLayout>
</StackLayout>
</ContentView.Content>
您会在这里看到对话套件调用上述几个这样的
public Task<string> GetInputTextAsync(string title, string message,string currentText = null, Keyboard keyboard = null)
{
if (keyboard == null) keyboard = Keyboard.Default;
var cts = new TaskCompletionSource<string>();
var _dialogView = new Plugin.DialogKit.Views.InputView(title, message,currentText,keyboard);
_dialogView.FocusEntry();
_dialogView.Picked += (s, o) => { cts.SetResult(o); PopupNavigation.PopAsync(); };
PopupNavigation.PushAsync(new PopupPage { Content = _dialogView });
return cts.Task;
}
正如你所看到的那样,它的位置是错误的,因为它在弹出视图之前是错误的。
public void FocusEntry() { txtInput.Focus(); }
【问题讨论】:
-
只调用条目的焦点事件
-
@Jason 该条目位于插件对话框工具包中,除了告诉它显示数字文本框外,我无法控制它。
-
@Jason 我试图让它弹出,但它仍然没有工作输入字段在 rg 弹出窗口中。
-
@Jason 请看我上面的编辑。
-
@rogue39nin 鉴于这是一个外部库,您可以:创建一个包含更改的拉取请求并希望维护者“快速”响应,或者您可以进行 PR 但同时分叉项目并进行更改并使用 dll,直到 PR 被合并并且您的更改成为原始 repo 的一部分。
标签: xamarin.forms