3

I attempted to use EventToCommandBehavior like in below examples:

https://github.com/dotnet-architecture/eShopOnContainers/blob/dev/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Behaviors/EventToCommandBehavior.cs

https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/behaviors/reusable/event-to-command-behavior/

Problem is that the Command bindable property is not being set. I found many articles about similar issues but none of them resolved my problem. Have anyone similar problems?

My event to command behavior class is 1 : 1 like in first url.

My view:

<AbsoluteLayout
    VerticalOptions="FillAndExpand" 
    HorizontalOptions="FillAndExpand"
    IsVisible="True">
    <WebView 
        AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
        AbsoluteLayout.LayoutFlags="All"
        Source ="{Binding WebViewSource}">
        <WebView.Behaviors>
            <behaviors:EventToCommandBehavior
                            EventName="Navigating"
                            EventArgsConverter="{StaticResource WebNavigatingEventArgsConverter}"
                            Command="{Binding OnWebViewNavigatingCommand}" />
        </WebView.Behaviors>
    </WebView>
</AbsoluteLayout>

Fragment of the view model:

    public ICommand OnWebViewNavigatingCommand => new Command<string>(async (url) => await OnWebViewNavigatingAsync(url));

    private async Task OnWebViewNavigatingAsync(string url)
    {
        // Logic
    }
Piotr
  • 89
  • 2
  • 8

0 Answers0