Skip to content

[Bug] Cannot navigate via EventToCommandBehavior in XAML #2484

Closed
@Nate129

Description

Description

When attempting to navigate via XAML and EventToCommandBehavior like so:

<ListView.Behaviors>
      <prism:EventToCommandBehavior EventName="ItemTapped"
                                    Command="{prism:NavigateTo 'DetailPage'}"
                                    EventArgsParameterPath="Item" />
</ListView.Behaviors>

The following exception is thrown:

System.ArgumentNullException: 'Value cannot be null.
Parameter name: TargetElement'

Steps to Reproduce

  1. Setup a ListView containing elements in XAML
  2. Use EventToCommandBehavior to execute a command on the ItemTapped event
  3. Use Prism XAML navigation in the Command property for the EventToCommandBehavior
  4. The exception is thrown when tapping an item in the ListView

Expected Behavior

The navigation to occur when tapping the item.

Actual Behavior

The above exception is thrown.

Basic Information

  • Version with issue: 8.1.97
  • Last known good version: n/a
  • Xamarin.Forms version: 5.0.0.2012
  • IDE: Visual Studio 16.9.6

Reproduction Link

A Visual Studio solution that demonstrates the issue is here. Run the app on Android, tap a name in the ListView, the exception will occur.

Thanks!

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions