In my case, I have a dynamically created entry in a grid. I want to set focus on the next entry. Can someone help me out on this?
`if ((donationTypeList != null) && (donationTypeList.Count() > 0))
{
foreach (var item in donationTypeList)
{
var frame = new Frame();
var stacklayout = new StackLayout() { Orientation = StackOrientation.Vertical };
var grid = new Grid();
var label = new Label() { Text = item.name, ClassId = "1" };
var xentry = new XEntry() { VerticalOptions = LayoutOptions.End, PlaceholderColor = Color.Black, Placeholder = Constants.ZeroDollar, FontSize = 14, HeightRequest = 50, TextColor = Color.Black };
xEntries.Add(xentry);
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
grid.Children.Add(label, 0, 0);
grid.Children.Add(xentry, 1, 0);
stacklayout.Children.Add(grid);
frame.Content = stacklayout;
customizedFlexlayout.Children.Add(frame);
if (item.amount != null && Convert.ToDouble(item.amount) != 0)
{
xentry.Text = Constants.Dollar + item.amount;
frame.BackgroundColor = Color.FromHex("#0383BE");
label.TextColor = Color.White;
}
xentry.Focused += (s, e) =>
{
frame.BackgroundColor = Color.FromHex("#054a90");
label.TextColor = Color.White;
};
xentry.TextChanged += (s, e) =>
{
string text = xentry.Text;
if (text.Contains('.'))
{
int count = text.Length - text.IndexOf(".") - 1;
if (count > 2)
xentry.Text = text.Substring(0, text.Length - 1);
}
};
xentry.Unfocused += (s, e) =>
{
donationCatButtons.IsEnabled = false;
if (!string.IsNullOrEmpty(xentry.Text))
{
if ((xentry.Text == Constants.ZeroDollar) || (Convert.ToDouble(xentry.Text.Trim('$')) == 0))
{
frame.BackgroundColor = Color.FromHex("#EEEFEF");
label.TextColor = Color.FromHex("#054A90");
item.amount = 0.ToString();
xentry.Text = "";
}
else
{
frame.BackgroundColor = Color.FromHex("#0383BE");
label.TextColor = Color.White;
if (item.fundsMaxLimit != "" && Convert.ToDouble(item.fundsMaxLimit) > 0 && Convert.ToDouble(xentry.Text.Trim('$')) > Convert.ToDouble(item.fundsMaxLimit))
{
DisplayAlert(Constants.MaxLimitTitle, "You can not donate more than $" + item.fundsMaxLimit + " for " + item.name + ".", Constants.Ok);
item.amount = string.Format("{0:F2}", Convert.ToDouble(xentry.Text.Trim('$').TrimStart(new Char[] { '0' })));
}
else
item.amount = string.Format("{0:F2}", Convert.ToDouble(xentry.Text.Trim('$').TrimStart(new Char[] { '0' })));
xentry.Text = Constants.Dollar + item.amount;
}
}
else
{
xentry.Text = Constants.ZeroDollar;
item.amount = 0.ToString();
frame.BackgroundColor = Color.FromHex("#EEEFEF");
label.TextColor = Color.FromHex("#054A90");
}
foreach (var designation in donationTypeList)
{
if (designation.amount != 0.ToString() && designation.amount != null && designation.amount != "")
donationCatButtons.IsEnabled = true;
}
foreach (var designation in donationTypeList)
{
if (designation.fundsMaxLimit != "" && Convert.ToDouble(designation.fundsMaxLimit) > 0 &&
Convert.ToDouble(designation.amount) > Convert.ToDouble(designation.fundsMaxLimit))
donationCatButtons.IsEnabled = false;
}
};
}
}
else
DisplayNoContentFrame(Constants.NoSearchResultMessage);
}`