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

Binding a command and a CommandParameter in the same view

$
0
0

Hello,

I have an Entry and a Button. I want the command "CallWebServiceCommand" to be called when I press the button. The call to that command needs to include the url of the web service as a CommandParameter. The BindingContext is set to the ViewModel of the page.

<StackLayout>
    <Entry x:Name="url" Text="http://examplewebservice.com/?wsdl" />
    <Button Text="Call web service" Command="{Binding CallWebServiceCommand}" CommandParameter="{Binding ???}" />
</StackLayout>

The CommandParameter property of the button needs to reference the Text property of the entry. In WPF, I could do something like this:

<Button Text="Call web service" Command="{Binding CallWebServiceCommand}" CommandParameter="{Binding ElementName=url, Path=Text}" />

I know that it's not possible to have multiple binding contexts per view, but what would be a good workaround for this particular situation?


Viewing all articles
Browse latest Browse all 58056

Trending Articles