The entry field from the view is being populated on the content page. And in the view it is set as IsEnabled=false;
. Whenever it is set as disabled the value of the entry is not getting set.
Please take a look at the code below:
public class DetailsView : ContentView
{
public static Entry txtdetailsName;
public DetailsView()
{
Label lbldetailsName = new Label { Text = Resource.detailsName, FontAttributes = FontAttributes.Bold, Style = (Style)Application.Current.Resources["LabelStyle"] };
txtdetailsName = new Entry { Style = (Style)Application.Current.Resources["entryStyle"], IsEnabled = false };
StackLayout stDetailsName = new StackLayout
{
Padding = new Thickness(10, 0, 10, 0),
Children ={
lbldetailsName,
txtdetailsName
}
};
Content = new StackLayout
{
Padding = new Thickness(0, 0, 0, 20),
Children = {stDetailsName}
};
}
}
In content page:
public TestDetailsPage()
{
getDetailsData();
}
private async void getDetailsData()
{
Test test = new Test();
test = await getTestDetails();
loadView(test);
}
public async Task<Test> getTestDetails()
{
//...
return Test;
}
public void loadView(Test test)
{
DetailsView = new DetailsView();
//DetailsView.txtdetailsName.Text = Test.Name;
DetailsView.txtdetailsName.Text = "Some Text";
}
But it doesn't seem to set the value. Not sure what is causing the issue.
Edit
I tested the app on three android devices Micromax Canvas (Android version 6.0.1), Asus Zenfone(Android version 4.4.2) and Samsung Galaxy Tab 2 (Android version 4.1.2). On Asus zenfone and Samasung galaxy tab 2, the value for the disabled field is displayed as expected while on Micromax canvas the disabled text-boxes are empty.
Android version could be the issue?