User371688 posted
each clicked button means new entry and how can i give them x:name?
In file xxPage.xaml
,we can give a view x:Name
, but if we define a view in xxPage.cs ,we can't give them x:Name
.
But we can create a new instance name for them, just as the varivale debiEntry
for the new Entry that you posted above:
Entry debiEntry = new Entry();
And we can access the entry's text as follows:
private void Button_Clicked(object sender, EventArgs e)
{
Entry debiEntry = new Entry { };
debi.Children.Add(debiEntry);
debiEntry.Text = "test string";
System.Diagnostics.Debug.WriteLine("debiEntry's Text = " + debiEntry.Text);
}
And if you add many entries in your pages, you can access the value of these entries as follows:
private void GetValueButton_Clicked(object sender, EventArgs e)
{
var views = debi.Children;
foreach(var mView in views) {
if(mView is Entry) {
Debug.WriteLine(" an entry Text = " + ((Entry)mView).Text);
}
}
}
Xamarin forums are migrating to a new home on Microsoft Q&A!
We invite you to post new questions in the Xamarin forums’ new home on Microsoft Q&A!
For more information, please refer to this sticky post.