I have some input fields to enter details. At the mid of entering, I wish to erase all details before I save it if I click a button like "cancel". I used name reference (x:Name
), the '.Text
' property, and using Clicked
property, but I am not able to erase all of the fields on the click. So I want to reload the same page on button click as it becomes refreshed, looks as new as it was before entering details. How can I do that?
xaml part: (firstNameTxtBox field gets cleared but lastNameTxtBox does't)
<Label HorizontalTextAlignment="Start" FontSize="14" FontFamily="Helvetica" Margin="10,0,0,0" >
<Label.FormattedText>
<FormattedString>
<Span Text="Your first name " TextColor="#2D2926"/>
<Span Text="*" TextColor="#AB2328"/>
</FormattedString>
</Label.FormattedText>
</Label>
<control:KFOLiteEntry x:Name="firstNameTxtBox"
IsMandatory="true"
IsEnabled="{Binding IsFirstNameEnabled, Mode=OneWay}"
MaxLength="40"
Text="{Binding FirstName, Mode=TwoWay}"
HeightRequest="40"
CornerRadius="2"
BorderWidth="1"
BackgroundColor="#FAFAFA"
Margin="10,0,0,24"
Placeholder="First name"/>
<Label HorizontalTextAlignment="Start" FontSize="14" FontFamily="Helvetica" Margin="30,0,0,0">
<Label.FormattedText>
<FormattedString>
<Span Text="Your last name " TextColor="#2D2926"/>
<Span Text="*" TextColor="#AB2328"/>
</FormattedString>
</Label.FormattedText>
</Label>
<control:LastNameSearchBar x:Name="lastNameSearchBar"
ItemsSource="{Binding PreAuthVisitorList, Mode=TwoWay}" />
<control:KFOLiteEntry x:Name="lastNametxtBox"
IsMandatory="true"
IsEnabled="{Binding IsLastNameEnabled, Mode=OneWay}"
MaxLength="40"
Text="{Binding LastName, Mode=TwoWay}"
Placeholder="Last Name"
HeightRequest="40"
CornerRadius="2"
Margin="30,0,0,24"
BorderWidth="1"
BackgroundColor="#FAFAFA"/>
Button Code:
<Button x:Name="btnCancelCheckIn"
HorizontalOptions="StartAndExpand"
WidthRequest="163"
HeightRequest="40"
CornerRadius="2"
Text="Cancel"
TextColor="White"
Margin="0,68,0,10"
BackgroundColor="#AB2328"
Opacity=".3"
IsEnabled="False"
IsVisible="False"
Clicked="OnCancelChcekInClicked"/>
xaml.cs
button click function:
public void OnCancelChcekInClicked(object sender, EventArgs e)
{
acCompanies.Text = "";
Visitingtxt.Text = "";
firstNameTxtBox.Text = "";
lastNametxtBox.Text = "";
visitorCompanyTxtBox.Text = "";
}