corradocavalli / Corcav.Behaviors

Behaviors Plugin for Xamarin.Forms
53 stars 17 forks source link

No Property of name Interaction.Behaviors found #4

Closed oskaremil closed 9 years ago

oskaremil commented 9 years ago

I tried a basic implementation of the EventToCommand.

Using VS2015, Xamarin.Forms 1.4.4.6392 (installed in PCL and platform-specific projects) and Corcav.Behaviors 2.0.0 (installed in PCL and platform-specific projects) I have this xaml:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:login="clr-namespace:Client.ViewModels.Login;assembly=Client"
             xmlns:b="clr-namespace:Corcav.Behaviors;assembly=Corcav.Behaviors"
             x:Class="Client.Views.Login.Settings">
    <ContentPage.BindingContext>
        <login:SettingsViewModel/>
    </ContentPage.BindingContext>
    <b:Interaction.Behaviors>
      <b:EventToCommand EventName="Disappearing" Command="{Binding SaveCommand}"/>
    </b:Interaction.Behaviors>

    <StackLayout Orientation="Vertical">
        <!-- -->
    </StackLayout>

</ContentPage>

There seems to be a missing link somewhere...The project compiles but crashes when the application window is opening.

Exception from Windows Phone project:

Position 11:8. No Property of name Interaction.Behaviors found
   at Xamarin.Forms.Xaml.ApplyPropertiesVisitor.SetPropertyValue(Object xamlelement, XmlName propertyName, Object value, BindableObject rootElement, INode node, HydratationContext context, IXmlLineInfo lineInfo)
   at Xamarin.Forms.Xaml.ApplyPropertiesVisitor.Visit(ElementNode node, INode parentNode)
   at Xamarin.Forms.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
   at Xamarin.Forms.Xaml.RootNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
   at Xamarin.Forms.Xaml.XamlLoader.Load(BindableObject view, String xaml)
   at Xamarin.Forms.Xaml.XamlLoader.Load(BindableObject view, Type callingType)
   at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[TView](TView view, Type callingType)
   at Client.Views.Login.Settings.InitializeComponent()
   at Client.Views.Login.Settings..ctor()

A similar error when I start the Android project:

08-31 21:28:10.833 I/MonoDroid( 1829): UNHANDLED EXCEPTION:
08-31 21:28:10.835 I/MonoDroid( 1829): Xamarin.Forms.Xaml.XamlParseException: Position 11:8. No Property of name Interaction.Behaviors found
08-31 21:28:10.835 I/MonoDroid( 1829):   at Xamarin.Forms.Xaml.ApplyPropertiesVisitor.SetPropertyValue (System.Object xamlelement, XmlName propertyName, System.Object value, Xamarin.Forms.BindableObject rootElement, INode node, Xamarin.Forms.Xaml.HydratationContext context, IXmlLineInfo lineInfo) [0x004fc] in <filename unknown>:0 
08-31 21:28:10.835 I/MonoDroid( 1829):   at Xamarin.Forms.Xaml.ApplyPropertiesVisitor.Visit (Xamarin.Forms.Xaml.ElementNode node, INode parentNode) [0x000cb] in <filename unknown>:0 
08-31 21:28:10.835 I/MonoDroid( 1829):   at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x000b5] in <filename unknown>:0 
08-31 21:28:10.835 I/MonoDroid( 1829):   at Xamarin.Forms.Xaml.RootNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00030] in <filename unknown>:0 
08-31 21:28:10.835 I/MonoDroid( 1829):   at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.String xaml) [0x000cd] in <filename unknown>:0 
08-31 21:28:10.835 I/MonoDroid( 1829):   at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.Type callingType) [0x0002b] in <filename unknown>:0 
08-31 21:28:10.835 I/MonoDroid( 1829):   at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[Settings] (Client.Views.Login.Settings view, System.Type callingType) [0x00000] in <filename unknown>:0 
08-31 21:28:10.835 I/MonoDroid( 1829):   at Client.Views.Login.Settings.InitializeComponent () [0x00001] in C:\Workspace\-client\Client\Client\obj\Debug\Client.Views.Login.Settings.xaml.g.cs:27 
08-31 21:28:10.835 I/MonoDroid( 1829):   at Client.Views.Login.Settings..ctor () [0x00008] in C:\Workspace\-client\Client\Client\Views\Login\Settings.xaml.cs:12 
08-31 21:28:10.835 I/MonoDroid( 1829):   at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
08-31 21:28:10.835 I/MonoDroid( 1829):   at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <filename unknown>:0 
08-31 21:28:10.838 W/art     ( 1829): JNI RegisterNativeMethods: attempt to register 0 native methods for md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable
08-31 21:28:10.838 D/AndroidRuntime( 1829): Shutting down VM
oskaremil commented 9 years ago

Fixed.

I thougt BehaviorCollection was only necessary when adding multiple commands. Tricked by IntelliSense

<b:Interaction.Behaviors>
      <b:BehaviorCollection>
        <b:EventToCommand EventName="Disappearing" Command="{Binding SaveCommand}"/>
      </b:BehaviorCollection>
    </b:Interaction.Behaviors>