Hey Good Day Im really having a hard time trying to change the value of entrycell at run time my code goes this way:
reg.xaml
<TableSection Title="CREDENTIAL">
<EntryCell Label="Username:" Text="09068100820" Keyboard="Text" />
<EntryCell Label="Password:" x:Name="TxtPassword" Keyboard="Text" />
<EntryCell Label="Ref Code:" x:Name="TxtRefCodes" Keyboard="Text" />
<ViewCell>
<ContentView Padding="0,0">
<ContentView.Padding>
<OnPlatform x:TypeArguments="Thickness" iOS="10,0" WinPhone="0,15,0,0" />
</ContentView.Padding>
<ContentView.Content>
<Button x:Name="BntRegz" Clicked="BntRegz_OnClicked" BackgroundColor="#fd6d6d" Text="SUBMIT" TextColor="White"/>
</ContentView.Content>
</ContentView>
</ViewCell>
</TableSection>
reg.xaml.cs
private void BntRegz_OnClicked(object sender, EventArgs e)
{
var txt = this.FindByName<EntryCell>("TxtPassword");
txt.Text = "Test This";
}
Your code is correct, but Placeholder
is only shown if the EntryCell
is empty.
Example:
private void BntRegz_OnClicked(object sender, EventArgs e)
{
var txt = this.FindByName<EntryCell>("TxtRefCodes");
if (string.IsNullOrEmpty(txt.Placeholder))
{
txt.Placeholder = "EntryCell is Empty";
}
else
{
txt.Text = "Overwrite value entered by user";
}
}
Empty TxtRefCodes
Entry and user clicks Submit, Placeholder
is shown:
User enters text into TxtRefCodes
:
User clicks Submit and his entry is overwritten: