locked
How can i reach a button in a Cell view RRS feed

  • Question

  • User286549 posted

    How can i reach a button in a view cell using x:name in the code page cant see it pls i want 2 change the text dynamically

    Monday, January 30, 2017 6:29 PM

Answers

  • User169828 posted

    i recommend looking into the MVVM pattern.

    you would use a Binding to set the text.

    <Button Text="{Binding MyButtonText}" />

    public string MyButtonText {get;set;}

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, January 30, 2017 7:57 PM

All replies

  • User180523 posted

    You can't. x:Name is meaningless on a template since there are multiple instances of the object: one for each item in the source collection.

    You shouldn't be trying to change UI elements from code anyway - that's very bad practice.

    To do what you want you'll need to bind the text value to a property on the model or ViewModel.

    Monday, January 30, 2017 6:33 PM
  • User286549 posted

    i want to change the language of that button thats all how can i do that please help me Out

    Monday, January 30, 2017 6:34 PM
  • User286549 posted

    cant i use via a property or something ?

    Monday, January 30, 2017 6:46 PM
  • User169828 posted

    i recommend looking into the MVVM pattern.

    you would use a Binding to set the text.

    <Button Text="{Binding MyButtonText}" />

    public string MyButtonText {get;set;}

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, January 30, 2017 7:57 PM