Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot assign property "Actions" #14

Open
ebicoglu opened this issue May 9, 2018 · 11 comments
Open

Cannot assign property "Actions" #14

ebicoglu opened this issue May 9, 2018 · 11 comments

Comments

@ebicoglu
Copy link

ebicoglu commented May 9, 2018

Hi,

I've been using Behaviors without a problem until Xamarin.Forms v3.0.
When I updated to Xamarin Forms v3.0, I got the below exception

Cannot assign property "Actions": Property does not exist, or is not assignable, or mismatching type between value and property

MyView.xaml

  <ContentPage.Behaviors>
        <behaviors:EventHandlerBehavior EventName="Appearing">
            <behaviors:InvokeCommandAction Command="{Binding PageAppearingCommand}" />
        </behaviors:EventHandlerBehavior>
    </ContentPage.Behaviors>

MyViewModel.cs

public ICommand PageAppearingCommand => new Command(async () =>
{
    await PageAppearingAsync();
});

image

@marcominerva
Copy link

I have the same issue too. Using the sample from this repo, with Xamarin.Forms v2.5.1.527436, everything works like a charm. As soon as I update it to 3.0.0.446417 (in all the projects), I get the "Cannot assign property Actions" error (even after a clean & rebuild).

@davidbritch
Copy link
Owner

Thanks for letting me know. I'll look into it.

@MaxenceMax
Copy link

Same for me since few days and update.

@davidbritch
Copy link
Owner

davidbritch commented May 14, 2018

A temporary fix, to unblock people, is to explicitly declare an ActionCollection around the actions:

<ListView x:Name="listView" ItemsSource="{Binding People}">
    <ListView.Behaviors>
        <behaviors:EventHandlerBehavior EventName="ItemSelected">
            <behaviors:ActionCollection>
                <behaviors:InvokeCommandAction Command="{Binding ItemSelectedCommand}" Converter="{StaticResource SelectedItemConverter}" />
                <behaviors:InvokeCommandAction Command="{Binding OutputAgeCommand}" Converter="{StaticResource SelectedItemConverter}" />
            </behaviors:ActionCollection>
        </behaviors:EventHandlerBehavior>
    </ListView.Behaviors>
</ListView>

In the meantime, I'll work on fixing this.

@davidbritch
Copy link
Owner

This is now fixed, but I'm taking the opportunity to add a couple of extra bits of new functionality, so it'll be the end of the week before updated source code/NuGet is pushed live.

@davidbritch
Copy link
Owner

This is now fixed in v1.4.0 of the NuGet package.

@sgrassie
Copy link

sgrassie commented Jul 25, 2018

I know this issue is closed, but I'm still having exactly the same problem, using 1.4.0 and Xamarin.Forms 3.1.0.637273. The given work around still works, so not blocked.

Seems I was too hasty in my previous assertion, cleaning the project and restarting VS seems to have sorted things out

@sgrassie
Copy link

Sorry, it seems that I can't get it work. Everything compiles, but the commands don't react to the events, e.g. the Appearing event doesn't fire the command I've bound to it.

@davidbritch
Copy link
Owner

@sgrassie

Have you get a small repo case for this (ZIP ideally)?

@davidbritch davidbritch reopened this Jul 26, 2018
@davidbritch
Copy link
Owner

I've just created two new projects:

  1. .NET Standard based Forms app.
  2. PCL based Forms app.

In both cases I was able to install v1.4 of the Behaviors library, and use it to invoke commands in view models.

Without a firm repo case there's nothing more I can do about this.

@UnreachableCode
Copy link

UnreachableCode commented Nov 13, 2018

I seem to be getting the same problem in a .NETStandard project with Xamarin Forms 3.2. I will post a repo reproducing the issue when I can.

@sgrassie I have the same issue. Were you able to fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants