Serial Kisser
Serial Kisser

Reputation: 131

MVVMCross Features

I'am a newbie in MVVMCross and I was wondering if an expert can answer a couple of my questions.

  1. I want to handle my virtual keyboard (custom keyboard(similar to the android keyboard) on my android device to type only at a focused edittextfield. I dont know how to do that.

  2. Is there a way to access the control's (any control - button , edittextfield) properties directly from my viewmodel? Maybe you can explain a best practice of handling control events through viewmodels?

Thanks in advance.

Upvotes: 1

Views: 458

Answers (2)

Stefan
Stefan

Reputation: 975

  1. No idea what exactly you mean here?
  2. No, this is and should not be possible by design. -> You should not have any direct access from the ViewModel to your View. The connection between this two elements is done using DataBinding. This means whenever you want to access a property of the control, expose a property on your ViewModel for this and bind them together in the View.

For Example when you want to access the "Text"-Property of your EditText. Then Create a Property on your ViewModel (YourTextProperty for example) and then use DataBinding. On Android this would like something like:

<EditText local:MvxBind="Text YourTextProperty" />

The MvvmCross Binding-Engine will then automatically execute the setter of your property when the control does change this value...

Upvotes: 3

Serial Kisser
Serial Kisser

Reputation: 131

Thanks for the reply.

What I was looking actually was the FindByViewID in my view.cs to get the control properties and events and then pass it to properties in the Viewmodel as you mentioned above.

Upvotes: 0

Related Questions