Skip to content

This repository contains a sample on How to add AlertDialog in the Syncfusion Xamarin.Android DataForm (SfDataForm)?

Notifications You must be signed in to change notification settings

SyncfusionExamples/dataform-alertdialog-xamarin-android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

How to add DataForm(SfDataForm) in AlertDialog in Xamarin.Android ?

You can add SfDataForm to alert dialog using the AlertDialog builder in Xamarin.Android.

Initialize SfDataForm, set DataObject and other requirements of SfDataForm in the button click event handler.

private void OnLogin(object sender, System.EventArgs e)
{
var dataForm = new SfDataForm(this);
dataForm.DataObject = new LoginInfo();
dataForm.CommitMode = CommitMode.PropertyChanged;
dataForm.RegisterEditor("Password", "Password");}

Initialize the AlertDialog.Builder and set SfDataForm as builder view.

private void OnLogin(object sender, System.EventArgs e)
{var builder = new AlertDialog.Builder(this);
builder.SetCancelable(false);
builder.SetTitle("Enter credentials");
builder.SetPositiveButton("Ok", (s1, e1) => {
});
builder.SetView(dataForm);}

For AlertDialog, set SoftInptMode to specify the action needs to be done on showing the soft keyboard. And, clear the NotFocusable flags to enable the soft keyboard and focus the fields of SfDataForm.

private void OnLogin(object sender, System.EventArgs e)
{AlertDialog dialog = builder.Show();
            dialog.Window.SetSoftInputMode(SoftInput.AdjustPan);
            dialog.Window.ClearFlags(WindowManagerFlags.NotFocusable | WindowManagerFlags.AltFocusableIm);
}

Output

DataFormAlertDialog

About

This repository contains a sample on How to add AlertDialog in the Syncfusion Xamarin.Android DataForm (SfDataForm)?

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages