Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Fix initial load when WhileEditing (#12765)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmacombe committed Nov 10, 2020
1 parent 640377c commit 91b883e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,25 @@ protected override void Init()
stack.Children.Add(new Label {Text = "Click the button to toggle the clear button visibility."});
stack.Children.Add(new Label { Text = "The default state when this page loaded is NEVER. The clear button should not be visible until you click toggle." });

Entry = new Entry
EntryToggle = new Entry
{
Text = "Clear Button: Never",
Text = "Clear Button: Never (toggles)",
ClearButtonVisibility = ClearButtonVisibility.Never
};
stack.Children.Add(Entry);
stack.Children.Add(EntryToggle);

EntryNever = new Entry
{
Text = "Clear Button: Never (Default Entry ClearButtonVisibility)"
};
stack.Children.Add(EntryNever);

EntryAlways = new Entry
{
Text = "Clear Button: Always (Set before load)",
ClearButtonVisibility = ClearButtonVisibility.WhileEditing
};
stack.Children.Add(EntryAlways);

var button = new Button { Text = "Toggle Clear Button State" };
button.Clicked += Button_Clicked;
Expand All @@ -28,22 +41,24 @@ protected override void Init()
Content = stack;
}

private void Button_Clicked(object sender, System.EventArgs e)
void Button_Clicked(object sender, System.EventArgs e)
{
if (Entry.ClearButtonVisibility == ClearButtonVisibility.Never)
if (EntryToggle.ClearButtonVisibility == ClearButtonVisibility.Never)
{
Entry.ClearButtonVisibility = ClearButtonVisibility.WhileEditing;
Entry.Text = "Clear Button: While Editing";
EntryToggle.ClearButtonVisibility = ClearButtonVisibility.WhileEditing;
EntryToggle.Text = "Clear Button: While Editing (toggles)";
}
else
{
Entry.ClearButtonVisibility = ClearButtonVisibility.Never;
Entry.Text = "Clear Button: Never";
EntryToggle.ClearButtonVisibility = ClearButtonVisibility.Never;
EntryToggle.Text = "Clear Button: Never (toggles)";
}
Entry.Focus();
EntryToggle.Focus();
}

public Entry Entry { get; set; }
public Entry EntryToggle { get; set; }
public Entry EntryAlways { get; set; }
public Entry EntryNever { get; set; }

}
}
2 changes: 1 addition & 1 deletion Xamarin.Forms.Platform.UAP/FormsTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ void UpdateClearButtonVisible()
{
if (ClearButtonVisible && !states.Contains(visibleState))
states.Add(visibleState);
else
else if(!ClearButtonVisible)
states.Remove(visibleState);
}
}
Expand Down

0 comments on commit 91b883e

Please sign in to comment.