Hi,
currently i am Xamarin.Forms with Android and it's pretty cool. But i now faced a problem and i cant find a solution so far.
Inside my PCL i've created this class
public class DDSButton : View
{
public DDSButton ()
{
}
public static readonly BindableProperty BackgroundImageProperty =
BindableProperty.Create<DDSButton,ImageSource> (p => p.BackgroundImage, null);
public ImageSource BackgroundImage {
get { return (ImageSource)GetValue (BackgroundImageProperty); }
set { SetValue (BackgroundImageProperty, value); }
}
}
Inside my droid i've the DDSButtonRenderer
[assembly: ExportRenderer(typeof(DDSButton), typeof(DDSButtonRenderer))]
namespace HelloX.Droid
{
public class DDSButtonRenderer : ViewRenderer<DDSButton, Android.Widget.ImageButton>
{
protected override void OnElementChanged (ElementChangedEventArgs<DDSButton> e)
{
base.OnElementChanged (e);
if (e.OldElement != null || this.Element == null)
return;
var btn = new Android.Widget.ImageButton (Forms.Context);
btn.SetBackgroundColor (Android.Graphics.Color.Transparent);
btn.SetImageResource (HelloX.Droid.Resource.Drawable.BTN_Abbrechen);
SetNativeControl (btn);
}
}
}
How can i set the ImageResource of the ImageButton to the ImageResource of the Embedded Resource ?