嘿,好日子我真的很难在运行时尝试更改entrycell的值,我的代码是这样的:
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";
}
答案 0 :(得分:0)
您的代码是正确的,但Placeholder
仅在EntryCell
为空时显示。
示例:
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";
}
}
空TxtRefCodes
条目并且用户点击提交,显示Placeholder
:
用户将文字输入TxtRefCodes
:
用户点击“提交”并覆盖其条目: