Hi XamBoy,
Welcome to our Microsoft Q&A platform!
In my test, if the text in the entry is modified, the "Focused" event will be triggered when you back to the page again.
So here I have a workaround that you can create a static field to save the count of entries whose text has been modified.
static class EntryEditedCounterClass
{
public static List<int> editedEntryIndex = new List<int>();
}
Then subscribe to event "entry_Focused" and "entry_TextChanged" for each entry.
<StackLayout>
<Entry x:Name="entry1" Focused="entry_Focused" TextChanged="entry_TextChanged"/>
<Entry x:Name="entry2" Focused="entry_Focused" TextChanged="entry_TextChanged"/>
<Entry x:Name="entry3" Focused="entry_Focused" TextChanged="entry_TextChanged"/>
</StackLayout>
You also need to override "OnAppearing" to reset the "editedEntryIndex" when you reopen the page.
Here is a simple demo you can refer to.
int entrycount;
protected override void OnAppearing()
{
base.OnAppearing();
// reset editedEntryIndex
entrycount = EntryEditedCounterClass.editedEntryIndex.Count;
}
private void entry_Focused(object sender, FocusEventArgs e)
{
// if focused, call Unfocus()
if (entrycount > 0)
{
(sender as Entry).Unfocus();
entrycount--;
}
}
private void entry_TextChanged(object sender, TextChangedEventArgs e)
{
// add new index to editedEntryIndex
var entry = sender as Entry;
var entrylist = (entry.Parent as StackLayout).Children;
var entryindex = entrylist.IndexOf(entry);
if (EntryEditedCounterClass.editedEntryIndex.Contains(entryindex))
{
return;
}
else
{
EntryEditedCounterClass.editedEntryIndex.Add(entryindex);
}
}
Regards,
Kyle
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.