Giter Club home page Giter Club logo

behaviors's People

Contributors

davidbritch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

behaviors's Issues

Runtime linking problem in iOS

Reference to the PCL published over NuGET repostory is not working on iOS. The app gives me the following error at runtime:

System.IO.FileNotFoundException: Could not load file or assembly 'Behaviors' or one of its dependencies

The Windows Universal and Android apps works well.

Behaviors in GestureRecognizers

Hi there, i have this code:
<Image Source="{Binding FavoriteIcon,Mode=TwoWay}"> <Image.GestureRecognizers> <TapGestureRecognizer Command="{Binding CommmandSetFavorite}"/> </Image.GestureRecognizers> </Image>

I would like that when touch it this'll make an animation of ScaleAction through GestureRecognizers, how could i do it?

Compatibility with RelayCommand (MVVMLight)

Hello and thanks for your great work. We are starting to use your package but won't be able to use it with already given RelayCommands from the existing viewmodels using the mvvm light framework. Is there a chance to get these two to work together, or do we have to map an ICommand to the RelayCommand in at logic level (viewmodel)? AFAIK, the mvvm light RelayCommand implements the ICommand.

When I use the ListViewSelected-Event with the ICommand (as stated in your samples), everything works fine. Bound to the RelayCommand, nothing gets fired/executed, not even breakpoints are being hitten.

Env: Xamarin Forms 3.2, Android/iOS-Projects, MVVMLight, .net standard 2.0, behaviors 1.4

Many thanks in advance.

ItemTapped event

Hi @davidbritch

I have this code

        InvokeCommandAction icsSelectedItem = new InvokeCommandAction();
        icsSelectedItem.SetBinding(InvokeCommandAction.CommandProperty, "ItemSelectedCommand");
        EventHandlerBehavior ehbSelectedItem = new EventHandlerBehavior() { EventName = "ItemSelected" };
        ehbSelectedItem.Actions.Add(icsSelectedItem);

It works fine.

But I would like to use ItemTapped event, not ItemSelected. If I change EventName to ItemTapped, It does not work...

AnimationDemoPage throws an exception when clicking on the button during animation

Hello David,

The AnimationDemoPage throws an exception when clicking on the button during animation:

System.InvalidOperationException: An attempt was made to transition a task to a final state when it had already completed.

I found how to inactivate the button during the animation:

<Button.Behaviors>
<behaviors:EventHandlerBehavior EventName="Clicked">
<behaviors:SetPropertyAction TargetObject="{x:Reference runAnimationButton}"
PropertyName="IsEnabled" Value="false" />
<behaviors:SetPropertyAction
TargetObject="{x:Reference stopAnimationButton}"
PropertyName="IsEnabled"
Value="true" />
<behaviors:SetPropertyAction
TargetObject="{x:Reference stopAnimationButton}"
PropertyName="IsVisible"
Value="true" />
...
<behaviors:SetPropertyAction
TargetObject="{x:Reference runAnimationButton}"
PropertyName="IsEnabled" Value="true" />
<behaviors:SetPropertyAction
TargetObject="{x:Reference stopAnimationButton}"
PropertyName="IsEnabled"
Value="false" />

But I did not find how to cancel the animation by clicking on the "Stop animation" button.
Here what I tried out:
Above code for stopAnimationButton plus:

<Button x:Name="stopAnimationButton" Text="Stop animation (ineffective)" IsVisible="true" IsEnabled="false">
    <Button.Behaviors>
        <behaviors:EventHandlerBehavior EventName="Clicked">
            <behaviors:InvokeMethodAction TargetObject="{x:Reference animationPage}" MethodName="OnStopAnimation" />
            <behaviors:SetPropertyAction TargetObject="{x:Reference runAnimationButton}" PropertyName="IsEnabled" Value="true" />
        </behaviors:EventHandlerBehavior>
    </Button.Behaviors>
</Button>



public void OnStopAnimation(object sender, EventArgs args)
{
	//KO no animation.Commit(.., "animationID", ...) defined: this.AbortAnimation("animationID";
	//KO still same runtime exception: ViewExtensions.**CancelAnimations**(image);
	ViewExtensions.**CancelAnimations**(this); //KO: no effect (but no exception neither)
}

Any idea?
Thanks.

Best regards,
Nikolas

System.Reflection.TargetInvocationException

i got this error on iOS platform only, does iOS need to something special to work ? It seems like the method "EventToCommandBehavior" can not be found in namespace. It's working on android platform.

Crashing on relase, working on debug

Hello !

I have declared in many pages something like this:

<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="xxx.Views.SplashPage"
    xmlns:behaviors="clr-namespace:Behaviors;assembly=Behaviors"
    xmlns:viewModelBase="clr-namespace:xxx.ViewModels.Base;assembly=xxx"
    xmlns:markupExtensions="clr-namespace:xxx.ComponentModel.MarkupExtensions;assembly=xxx.forms"
    viewModelBase:ViewModelLocator.AutoWireViewModel="true">
    <!-- PAGE BEHAVIORS -->
   <ContentPage.Behaviors>
        <behaviors:EventHandlerBehavior
            EventName="Appearing">
            <behaviors:ActionCollection>
                <behaviors:InvokeCommandAction
                    Command="{Binding Command}"
                    CommandParameter="{x:Reference Image}" />
            </behaviors:ActionCollection>
        </behaviors:EventHandlerBehavior>
    </ContentPage.Behaviors>
    <!-- PAGE CONTENT -->
    <ContentPage.Content>

When I compile in debug I can run the application physically or in the simulator, but when I compile in Release and when I navigate to a page that contains some behavior, my application suddenly crashes and I get:

Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.

Im using :
Xamarin.Mac
Version: 4.4.1.193 (Visual Studio Community)
Xamarin.iOS
Version: 11.12.0.4 (Visual Studio Community)
Xamarin.Forms
Version: 3.0.0.482510

Behaviors.Forms
Version: 1.4.0

Any Ideas? I've tried to remove the action collection tag or removing the command and CommandParameter with no success.

Thank you!

Behaviors.Forms Command not Executing

I am attempting to upgrade an existing Xamarin project to the latest versions of various libraries. The Xamarin forms themselves live in a shared .NET Standard library. My page has a ListView on it & I am attempting to capture the event fired when an item is 'chosen'. However, the ICommand in my ViewModel is not executing.

Could you (@davidbritch) possibly take a look at my StackOverflow Question on this?

NOTES:

  • I am using Xamarin.Forms 4.8...but had to downgrade Behaviors.Forms to 1.3 because the code is in a .NET Standard library.
  • If I upgrade to Behaviors.Forms 1.4 a design-time error occurs
  • However, ICommands are not executing

Get EventArgs from xaml for Command in viewmodel

Hi there, I trying to the SelectedItemChangedArgs on the SelectedItemChanged event but not entirely sure how to get the EventArgs, do I need to use a converter or is it passed into a parameter I can use?

<controls:Dropdown.Behaviors>
  <behaviors:EventHandlerBehavior EventName="SelectedItemChanged">
        <behaviors:InvokeCommandAction Command="{Binding SelectedItemChangedCommand}" CommandParameter="{Binding ??}" />
  </behaviors:EventHandlerBehavior>
</controls:Dropdown.Behaviors>

This is what I would like to do in the viewModel:

public Command<SelectedItemChangedArgs> SelectedItemChanged
        {
            get
            {
                return new Command<SelectedItemChangedArgs>(async (selectedItemChangedArgs) =>
                {              
                });
            }
        }

How can I retrieve the EventArgs in the command??

XF 3.5 Crashes

Awesome tool David.

When i upgrade to XF 3.5, the following crashed Android now when an item is tapped.

		```
     <ListView
			x:Name="ListView"
			IsVisible="{Binding Items, Converter={StaticResource EmptyListIsFalseConverter}}"
			AbsoluteLayout.LayoutFlags="XProportional,SizeProportional"
			AbsoluteLayout.LayoutBounds="0,45,1,1"
			android:ListView.IsFastScrollEnabled="True"
			ItemsSource="{ Binding Items }"
			CachingStrategy="RecycleElement"
			HasUnevenRows="True"
			RefreshCommand="{Binding RefreshCommand}"
			IsRefreshing="{Binding IsBusy}"
            
			IsPullToRefreshEnabled="true">


			<ListView.Behaviors>
				<behaviors:EventHandlerBehavior EventName="ItemTapped">
	
					<behaviors:InvokeCommandAction Command="{Binding ItemTappedCommand}" />
				</behaviors:EventHandlerBehavior>
			</ListView.Behaviors>

			<ListView.ItemTemplate>
				<DataTemplate  x:DataType="{x:Type addressBook:AddressBookItem}">
					<ViewCell>
						<template:AddressBookCell />
					</ViewCell>
				</DataTemplate>
			</ListView.ItemTemplate>

			<!-- Prevents ListView from hiding end under the Tab it's embedded in -->
			<ListView.Footer>
				  <StackLayout HeightRequest="50"></StackLayout>
			</ListView.Footer>
		</ListView>

Switch inside ListView

Hi @davidbritch
I have a Switch inside a ListView.

I would like to use EventHandlerBehavior with Toggled event, but I think I miss something:

                    <Switch Grid.Row="2"
                        Grid.Column="1"
                        WidthRequest="100"
                        HorizontalOptions="End"
                        VerticalOptions="End"                               
                        OnColor="{StaticResource Prada.ButtonForeground}"
                        IsToggled="{Binding IsOk, Mode=TwoWay}" >
                        <Switch.Behaviors>
                            <behaviors:EventHandlerBehavior EventName="Toggled">
                                <behaviors:InvokeCommandAction Command="{Binding ToggledCommand}"/>
                            </behaviors:EventHandlerBehavior>
                        </Switch.Behaviors>
                    </Switch>

can you help me?
Thanks

Cannot assign property "Actions"

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

Switch inside ListView

Hi @davidbritch
I have a Switch inside a ListView.

I would like to use EventHandlerBehavior with Toggled event, but I think I miss something:

                    <Switch Grid.Row="2"
                        Grid.Column="1"
                        WidthRequest="100"
                        HorizontalOptions="End"
                        VerticalOptions="End"                               
                        OnColor="{StaticResource Prada.ButtonForeground}"
                        IsToggled="{Binding IsOk, Mode=TwoWay}" >
                        <Switch.Behaviors>
                            <behaviors:EventHandlerBehavior EventName="Toggled">
                                <behaviors:InvokeCommandAction Command="{Binding ToggledCommand}"/>
                            </behaviors:EventHandlerBehavior>
                        </Switch.Behaviors>
                    </Switch>

can you help me?
Thanks

InvokeCommandAction not found in xmlns clr-namespace:Behaviors;assembly=Behaviors'

Hello! I recently came accros this awesome library and wanted to give it a try. However, when I try to use DataChangedBehavior and InvokeCommandAction I am getting the above-mentioned error. I have copied the use of the library from your sample code in the repo:

<StackLayout>
	<Label Text="Invoke Command when Data Changes" FontAttributes="Bold" HorizontalOptions="Center" />
	<Entry x:Name="entry" Placeholder="Enter Xamarin here">
		<Entry.Behaviors>
			<behaviors:DataChangedBehavior Binding="{Binding Path=Text, Source={x:Reference entry}}"
										   ComparisonCondition="Equal" Value="Xamarin">
				<behaviors:InvokeCommandAction Command="{Binding OutputMessageCommand}"
											   CommandParameter="{Binding Path=Text, Source={x:Reference entry}}" />
			</behaviors:DataChangedBehavior>
		</Entry.Behaviors>
	</Entry>
	<Label Text="{Binding MessageText}" />
</StackLayout>

Not running while XamlCompilationOptions.Skip (not XamlCompilationOptions.Compile)

Using the NuGet package v1.1.0 and don't use [assembly: XamlCompilation(XamlCompilationOptions.Compile)] the behaviors doesn't work.

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Xamarin.Forms.Xaml.XamlParseException: Position 11:8. Type behaviors:InvokeCommandAction not found in xmlns clr-namespace:Behaviors;assembly=Behaviors
   at Xamarin.Forms.Xaml.CreateValuesVisitor.Visit(ElementNode node, INode parentNode)
   at Xamarin.Forms.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
   at Xamarin.Forms.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode

The binary Behaviors.dll is built in debug mode.

Hi David,

I install your Behaviors for Xamarin.Forms 1.1.0 from Nuget.
When I publish my UWP app to Windows App Store, then got an error message:

Error Found: The debug configuration test detected the following errors:
The binary Behaviors.dll is built in debug mode.

So, I use dotPeek to check the Behaviors.dll properties, in Pdb File property:

y:\Repos\behaviors\Library\Behaviors\obj\Debug\Behaviors.pdb

Maybe you upload the debug mode dll to Nuget not release?

Thank you, and Sorry for my poor English.
Yute Lin

Could not resolve type

Hi @davidbritch

I have updated your Package to 1.4.0 and when I run the app to a real Device (Android 4.4)
I have this error

Unhandled Exception:

System.TypeLoadException: Could not resolve type with token 010000cc (from typeref, class/assembly Behaviors.BehaviorPropertiesBase, Behaviors, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null).

Returnig to 1.3.0 all works fine

Alessandro

Type not found

Hi,
I recently switched from shared project to PCL library.
Using the shared project, everything works great, but in the PCL project I get the message (XamlParseException), that the FadeAction type can't be found.

Do you have any suggestions?

InvokeCommandAction xaml designer error

Hello

I have the xaml below which compiles fine but shows a weird error on InvokeCommandAction when designing the xaml. This is happening in XF3.6
<behaviors:EventHandlerBehavior EventName="SlidedToIndex"> <behaviors:InvokeCommandAction Command="{Binding DaySelectedCommand}"/> </behaviors:EventHandlerBehavior>

With error: Property 'Actions' does not support values of type 'InvokeCommandAction'.

Have view listen to event on VM

Hello @davidbritch and thanks for this wonderful repo!

In my scenario I have a ViewModel that wants to signal the View to do a one-time action (animation etc.).

Does this library offer anything that can achieve that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.