The name does not exist in current context [error]

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"?>


        <ContentPage.Content >

               <ListView x:Name="list_menuPage" >
                                <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"/>



<MasterDetailPage.Detail >
    <ContentPage Padding="10" BackgroundColor="Green">


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 = "{0}";
private System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();

    public Menu()
        //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>>
        string obj = JsonConvert.SerializeObject(menuArray, Formatting.Indented);
        var content = await client.GetStringAsync(string.Format(Url, obj));
        originalList = JsonConvert.DeserializeObject <List<Models.MenuDetails>> (content);

           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





  • ShantimohanElchuriShantimohanElchuri USMember ✭✭✭✭✭

    @sucharitha Normally if Binding Source is not found, it will just defaults to null. So you will have to post the full text of the error message to decipher it properly and also exact place where the error occurs. How do you say it is the ImageButton that is causing the error. Once you do Binding, that control view need not have defined x:Name. That will be needed only if you want to access it in the Clicked event.

Sign In or Register to comment.