1

I am using Xamarin, MVVMCross and visual studio for Android development. Is there any way in android layout in Xamarin to reference the UI component in the VM as shown below in the code?

what is the purpose of having a reference to the entire UI-Component.?

code

 <Button 
            x:Name="buttonItem" 
            Text="{Binding ButtonText}" 
            BackgroundColor="{x:Static resx:AppConstants.TransparentColor}"
            BorderColor="{x:Static resx:AppConstants.TransparentColor}"
            HorizontalOptions="Start"
            />
user10776303
  • 241
  • 6
  • 16

2 Answers2

0

No you bind the properties of the button to properties in your view model. You don't bind your complete button to something in your view model.

JKL
  • 978
  • 7
  • 21
0

You should never reference UI components in your viewmodels. MVVM tries to maintain a certain separations of concerns. You should take a look at the databinding fundamentals for mvvmcross https://www.mvvmcross.com/documentation/fundamentals/data-binding.

Pavlos
  • 993
  • 7
  • 23