Mounika
Mounika

Reputation: 147

how to set binding command on focus in xamarin.forms

I want something like

when I am trying this it shows an error saying "Unable to cast object of type 'Xamarin.Forms.Xaml.ElementNode' to type 'Xamarin.Forms.Xaml.ValueNode'."

that means focused event doesn't support binding.But how can I achieve that

Upvotes: 4

Views: 2681

Answers (1)

Ben
Ben

Reputation: 2985

To invoke a command when an event fires, EventToCommandBehavior might be used; example:

<Entry Text="{Binding Text}">
    <Entry.Behaviors>
        <behaviors:EventToCommandBehavior EventName="Focused"
                                          Command="{Binding FocusedCommand}" />
    </Entry.Behaviors>
</Entry>

See also Event to Command Behavior sample.

Upvotes: 4

Related Questions