У меня есть страницы с вкладками в моем проекте, где я должен связать одни и те же элементы на всех трех страницах с вкладками. Но модель представления в этом случае не выполняется.
xaml:
<TabbedPage.Children>
<Views:TabPage1>
<Views:TabPage1.BindingContext>
<ViewModel:TabPage1VM/>
</Views:TabPage1.BindingContext>
</Views:TabPage1>
<Views:TabPage2>
<Views:TabPage2.BindingContext>
<ViewModel:TabPage2VM/>
</Views:TabPage2.BindingContext>
</Views:TabPage2>
<Views:TabPage3>
<Views:TabPage3.BindingContext>
<ViewModel:TabPage3VM/>
</Views:TabPage3.BindingContext>
</Views:TabPage3>
</TabbedPage.Children>
Теперь каждая Viewmodel наследует основную Viewmodel и в одной дочерней ViewModel:
RestClient temp = new RestClient();
var gettempdetails = temp.Servicetypes();
if (gettempdetails.status == "success")
{
listdetails = new List<ServiceDetail>();
foreach (Datum2 data in gettempdetails.service_details)
{
Datum3 Display = new Datum2();
Display.name = data.name;
Display.rate = data.rate;
Display.time = data.time;
Display.type = data.type;
Display.image = "uncheck.png";
}
Во время отладки вышеуказанный код не выполняется.Любое решение?Также вот код RestClient внутри дочерней модели представления:
public RestClient()
{
client = new HttpClient
{
MaxResponseContentBufferSize = 256000
};
}
public async Task<ServiceItem> Servicetypes(int shopid)
{
var formcontent = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string,string>("branch_id",Convert.ToString(shopid)),
});
var response = await client.PostAsync("http://saloonbooking.com/index.php/branch/get_single_branch_details/", formcontent);
var data = await response.Content.ReadAsStringAsync();
var status = JsonConvert.DeserializeObject<ServiceItem>(data);
return status;