你能低於
嘗試Page.Xaml
<Entry TextChanged="Handle_TextChanged" Text="EnteyText" Unfocused="Handle_Unfocused" Focused="Handle_Focused" x:Name="entry" HeightRequest="50" WidthRequest="100" BackgroundColor="Aqua"/>
<Button Text="Bind Text From Book" Clicked="Handle_Clicked" HeightRequest="50" WidthRequest="100" />
Page.Xaml.CS
bool isFocused;
string entryText="EnteyText";
void Handle_Focused(object sender, Xamarin.Forms.FocusEventArgs e)
{
isFocused = e.IsFocused;
}
void Handle_Unfocused(object sender, Xamarin.Forms.FocusEventArgs e)
{
isFocused = e.IsFocused;
}
void Handle_TextChanged(object sender, Xamarin.Forms.TextChangedEventArgs e)
{
if (!isFocused)
{
entryText = (sender as Entry).Text;
}
if (isFocused && entryText != e.NewTextValue)
{
(sender as Entry).Text = e.OldTextValue;
}
}
void Handle_Clicked(object sender, System.EventArgs e)
{
entry.Unfocus();
entry.Text = "Text from book";
}
你可以使用一個按鈕,或手勢添加到標籤,將複製標籤文本到剪貼板。 – Jason
您可以編輯子類並覆蓋文本更改的事件,以防止用戶更改文本。 – Slepz
嘗試創建渲染器並使其只讀 – Krishna