Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Can you manually invoke a control's behavior ?

$
0
0

Hi,

Here's a bit of context for what I want to do.

My app is built in a MVVM viewmodel first pattern.
I have a couple of Entry controls on my page, each with their Text property using binding to the viewmodel property.
In the viewmodel, there's a "Next" button, which uses an async command with the canExecute being set (to make sure you can't proceed to the next page if certain fields were not filled).

I'd like to use behaviors to have a "required field behavior" that would put the placeholder text in red when the field is empty, and I know this works. The thing is, if the person goes straight to the "Next" button, the canExecute of the command will prevent from going forward, but nothing will trigger the behavior on the fields that were skipped.

Is there a way that you could force the behaviors that were not triggered in that kind of context ? If not, I'll have to add the validation inside the page, which would duplicate the places where those checks are done, or add a bunch of bindable properties in my viewmodel for each and every placeholder and placeholder text color, which seems like a lot to me.

Thanks in advance for any advice!
Bruno


Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>