mrxten / XamEffects

📱 Xamarin.Forms UI effects
MIT License
248 stars 41 forks source link

How to add TouchEffects in C# #14

Closed Uaecrom closed 6 years ago

Uaecrom commented 6 years ago

Hello, I'm new to Xamarin.forms. I like so much your plugin it works perfectly with XAML. I'm trying to generate some customcontrols inside another customcontrol with C# code directly, but I don't know in this case how can I use XamEffect, can you give me a little help?

mrxten commented 6 years ago

Sure

var grid = new Grid();

TouchEffect.SetColor(grid, Color.Red);
Commands.SetTap(grid, new Command(() => {
    //some action;
}));
Commands.SetTapParameter(grid, new object());

//or through binding 
grid.SetBinding(TouchEffect.ColorProperty, "binding path");
grid.SetBinding(Commands.TapProperty, "binding path");
grid.SetBinding(Commands.TapParameterProperty, "binding path");
Uaecrom commented 6 years ago

Thanks a lot !

OKameric commented 5 years ago

Is it also possible to remove the effect with C# or via binding ?

mrxten commented 5 years ago

Ofc, set Color.Default for remove touch effect