【问题标题】:Include a text field inside an alert dialog在警报对话框中包含文本字段
【发布时间】:2018-04-07 04:02:16
【问题描述】:

当用户单击“添加”按钮时,我希望向用户显示一个警告对话框,允许他们在输入字段中输入商店编号。我对此进行了研究,但没有为 Xamarin.Forms 找到任何明确的解决方案。

在下面查看我尝试过的代码。我在我的 Xaml 中添加了一个输入字段并使其不可见。然后我添加了一个点击手势,这样一旦我的 FAB 被点击,输入字段现在就会在警报对话框中可见。但这不起作用。

Xaml:

<Image
    Grid.Column="0" Grid.Row="0"
    Source="add.png"
    HorizontalOptions="EndAndExpand"
    VerticalOptions="EndAndExpand"
    Margin="0,0,30,30"
    HeightRequest="45"
    WidthRequest="45">
    <Image.GestureRecognizers>
        <TapGestureRecognizer 
            Command="{Binding clickNewCard}"
            CommandParameter="3"
            Tapped="TapGestureRecognizer_Tapped"/>          
    </Image.GestureRecognizers>
</Image>

<Entry x:Name="StoreField" InputTransparent="True" IsVisible="False"/>

Xaml.cs

private async void TapGestureRecognizer_Tapped(object sender, EventArgs e)
{
    if (e != null)
    {
        StoreField.IsVisible = true;
        await DisplayAlert("Enter Store Number", StoreField.Text, "Add");
    }        
}

【问题讨论】:

标签: xaml xamarin.forms


【解决方案1】:

正如@Cole_Xia 提到的,有几个 NuGet 包可用于使用 Xamarin 表单创建自定义警报对话框,例如:

1.- https://github.com/rotorgames/Rg.Plugins.Popup

2.- https://github.com/michaeled/FormsPopup

3.- https://github.com/aritchie/userdialogs

我已经尝试过 Forms Popup,它确实有效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-12
    • 2018-10-23
    • 1970-01-01
    • 2011-11-19
    • 1970-01-01
    • 1970-01-01
    • 2014-12-15
    相关资源
    最近更新 更多