In many UI frameworks, the base UI element class (in XForms, a View) contains a .Tag property that allows a reference to an object be associated with the View. Is there an equivalent in Xamarin Forms?
My use case is the following:
- My Page constructs a collection of Buttons that are children of a
StackLayout. The number ofButtons can vary at run time. - Each
Buttonis associated with a feature in the app and is bound to the sameICommandin the page's view model. - I would like to associate (i.e. tag) each Button with a
FeatureViewModelso that when the user clicks any button, the command (which takes aFeatureViewModelargument) is executed.
A workaround would be for the Page to maintain a mapping of Button to FeatureViewModels and have each button's Clicked handler execute the view model's ICommand, which seems cheesy. 