I have a custom cell with a stack layout [with a label and a image button] in a list view when im trying to change the isVisibility of image button iam getting this error.
<?xml version="1.0" encoding="UTF-8"?>
<MasterDetailPage.Master>
<ContentPage.Content >
<ListView x:Name="list_menuPage" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout x:Name="ChildItems" Orientation="Horizontal">
<Label Text="{Binding NAME}" TextColor="Navy" HorizontalOptions="StartAndExpand"/>
<ImageButton Source="right_arrow.png" IsVisible="{Binding IsSelected}" x:Name="subListButton" HorizontalOptions="EndAndExpand" Margin="5,10" Clicked="Handle_Clicked"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage.Content>
</ContentPage>
</MasterDetailPage.Master>
<MasterDetailPage.Detail >
<ContentPage Padding="10" BackgroundColor="Green">
</ContentPage>
</MasterDetailPage.Detail>
using System;
using System.Collections;
using System.Collections.Generic;
using Newtonsoft.Json;
using Xamarin.Forms;
namespace LoginPage
{
public partial class Menu : MasterDetailPage
{
private const string Url = "http://techportsolutions.myddns.me:45152/eKontenService/RestServiceImpl.svc/getServiceData?InputData={0}";
private System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
public Menu()
{
InitializeComponent();
getMenu();
//list_menuPage.ItemTemplate = new DataTemplate(typeof(Models.SubListCell));
}
public List<Models.MenuDetails> originalList;
public List<Models.MenuDetails> topMenuItems;
async public void getMenu()
{
var parameters = new Dictionary<String, String>();
parameters["iFKCompanyID"] = "20";
parameters["iFKUserID"] = "55";
parameters["FK_DOCUMENT_TYPE_ID"] = "0";
parameters["iFKSalesmanID"] = "0";
parameters["iFKActorTypeID"] = "0";
parameters["sAPITemplate"] = "GETROLEMENUS";
parameters["sAPIValues"] = "|||";
var menuArray = new List<Dictionary<string, string>>
{
parameters
};
string obj = JsonConvert.SerializeObject(menuArray, Formatting.Indented);
var content = await client.GetStringAsync(string.Format(Url, obj));
originalList = JsonConvert.DeserializeObject <List<Models.MenuDetails>> (content);
if(originalList!=null)
{
topMenuItems = originalList.FindAll(s => s.IS_TOP_MENU == true && s.FK_PARENT_MENU_ID == null);
list_menuPage.ItemsSource = topMenuItems;
}
}
void Handle_Clicked(object sender, System.EventArgs e)
{
if (subListButton.IsVisible == true) // here im trying to use that and facing issue
{
}
}
}
}