Skip to content

Instantly share code, notes, and snippets.

@sthewissen
Last active September 9, 2017 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sthewissen/ffbae3716f7222201dd2057b8a629579 to your computer and use it in GitHub Desktop.
Save sthewissen/ffbae3716f7222201dd2057b8a629579 to your computer and use it in GitHub Desktop.
using System;
using SampleApp.Droid.Effects;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ResolutionGroupName("SuperAwesome")]
[assembly: ExportEffect(typeof(CatEffect), "CatEffect")]
namespace SampleApp.Droid.Effects
{
public class CatEffect : PlatformEffect
{
protected override void OnAttached()
{
try
{
if (Control is EntryEditText)
{
Control.SetBackgroundResource(Resource.Drawable.cat);
}
}
catch (Exception ex)
{
Console.WriteLine("Cannot set property on attached control. Error: ", ex.Message);
}
}
protected override void OnDetached()
{
// Back to white.
Control.SetBackgroundColor(Android.Graphics.Color.White);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment