how to get label control that is inside of listview

hi i am using xamarin form and how to get label control of list view on ItemAppearing event. and set IsVisible value in ItemAppearing event.

Tagged:

Answers

  • Sumit_SharmaSumit_Sharma USMember ✭✭✭

    How are you designing the page?

    via C# or XAML ?

  • shivendrama10shivendrama10 Member ✭✭
    edited February 12

    Hi I am using XAML

  • Sumit_SharmaSumit_Sharma USMember ✭✭✭

    Then you won't be able to get x:Name of your Label in code behind!

    can you share why you need x:Name in OnAppearing ?

  • shivendrama10shivendrama10 Member ✭✭

    I want to show text in label from ItemAppearing event it depend on id

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Its inside a ListView - You're not going to get it. Period. Because there is no single 'it' to get. If you have 100 items in your collection then you have 100 Label.

    The fact that you're even trying to reach in from code to get the label shows a real problem. With modern mobile software that's built on a XAML/MVVM design concepts we don't do that old 1998 WinForms type of approach. Nobody's done that stuff since... well... WPF 15 years ago.

    What you do in this decade is bind the Label to a property on your ViewModel.

    I'd urge you to stop working on this project until you can take some time to learn how things are architected in a Xamarin/Modern/MVVM design pattern app. Honestly: The time you spend learning first will be more than made up by not taking the wrong direction over and over and over.

    If you have no experience with MVVM design... no experience with databinding code to UI... etc. etc. then you need to first get a handle on that.

    Start with working the free textbook from cover to cover.
    https://blogs.msdn.microsoft.com/microsoft_press/2016/03/31/free-ebook-creating-mobile-apps-with-xamarin-forms/

    Feel free to hit up on-line tutorials sites. There are plenty. Here's mine:

  • shivendrama10shivendrama10 Member ✭✭

    hey ClintStLaurent
    Thank you for given resource link. Did asking question in forum is not good think.

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    @shivendrama10 said:
    hey ClintStLaurent
    Thank you for given resource link.

    You're welcome

    Did asking question in forum is not good think.

    No idea what you're trying to say there. You need a different translator

Sign In or Register to comment.