大家好,我一直在尋找將條目的占位符設定為斜體的解決方案。
uj5u.com熱心網友回復:
我有一個不尋常的解決方案來獲得你想要的效果。
首先,在 xaml 中將 FontAttributes 設定為 Italic,例如:
<Entry x:Name="test" FontAttributes="Italic" Placeholder="Placeholder" TextChanged="test_TextChanged"/>
然后,在 TextChanged 事件中將 FontAttributes 更改為 None,例如:
private void test_TextChanged(object sender, TextChangedEventArgs e)
{
Entry entry = sender as Entry;
if(entry.Text.Length > 0)
{
entry.FontAttributes = FontAttributes.None;
}
else
{
entry.FontAttributes = FontAttributes.Italic;
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/490090.html
上一篇:Xamarin表單中的影像輸入
