public static class InputPopup { public static Task<string> ShowAsync() { var source = new TaskCompletionSource<string>(); var popup = new SfPopupLayout(); var entry = new Entry(); entry.TextChanged += (s, e) => { source.SetResult(e.NewTextValue); }; popup.Content = entry; popup.Show(); return source.Task; } }
var input = await InputPopup.ShowAsync();
|
public class App : Application
{
internal static SfPopupLayout popupLayout;
public App()
{
popupLayout = new SfPopupLayout();
var button = new Button();
button.Clicked += Button_Clicked;
button.Text = "Click To Show Popup";
var stackLayout = new StackLayout();
stackLayout.Orientation = StackOrientation.Vertical;
stackLayout.Children.Add(button);
popupLayout.Content = stackLayout;
MainPage = new ContentPage() { Content = popupLayout };
}
private void Button_Clicked(object sender, EventArgs e)
{
InputPopup.Show();
}
}
public static class InputPopup
{
static Entry entry;
public static void Show()
{
entry = new Entry();
entry.Text = "You can customize the popup!!!";
entry.TextColor = Color.Black;
entry.TextChanged += Entry_TextChanged;
App.popupLayout.PopupView.ContentTemplate = new DataTemplate(() => { return entry; });
App.popupLayout.Show();
}
private static void Entry_TextChanged(object sender, TextChangedEventArgs e)
{
}
} |