Forum Xamarin.Forms

Problem with MVVM and Prism in Xamarin.Forms

LouisaLouisa USMember ✭✭

I have a problem with new Prism 6.3 which was released recently. I'm trying to use new feature of Prism 6.3 so EventToCommandBehavior. It works on Android but on iOS I have exception:

EventToCommandBehavior not found in xmlns clr-namespace:Prism.Behaviors

which is weird, because the same namespace is found by Android. So the error message is probably totally misleading.

Anyway the code is super simple. I also have entire project (with packages and everything) on github, here:

**If you don't know how to solve it, can you just get the code from repo and try to run it? also if you could add info about your config, like mac version..


<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns=""
  <Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" />

  <ListView ItemsSource="{Binding People}">
      <b:EventToCommandBehavior Command="{Binding PersonSelectedCommand}"
                                        EventArgsParameterPath="Item" />


using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PrismDemo
    public class StartPageViewModel : BindableBase
        public ObservableCollection<string> People { get; set; }

        public StartPageViewModel()
            People = new ObservableCollection<string>();

        public DelegateCommand<string> PersonSelectedCommand => new DelegateCommand<string>(OnPersonSelectedCommandExecuted);        
        void OnPersonSelectedCommandExecuted(string name)
            Debug.WriteLine("Hi " + name + "!");

That's IT!

The exception is while starting the app (again, it's on iOS only)

Best Answer


  • LouisaLouisa USMember ✭✭

    @NMackay Thanks! I will have a chance to test it in a few hours! Will let you know how it went

    BTW. Wait, I don't get it.. Unity? The game engine? Do you know if the solution would be the same if I want to use CocosSharp for example? Do I still need to add Unity?

  • NMackayNMackay GBInsider, University admin


    No, it's Unity the IoC container, not the games engine :smile:

    Prism is designed round the principles of dependency injection so it's better to down that route with Prism, you'll need it for example to inject the navigation service into your viewmodels. Using Unity won't stop you using CocosSharp in your app.

    Let me know you you get on.

  • LouisaLouisa USMember ✭✭

    @NMackay your project works great! Thanks! I will probably use IoC after all...

    But it's still bugging me.. if it's possible to do it without IoC container. When someone has just one view and viewmodel.

Sign In or Register to comment.