Reputation: 892
after I finally managed to setup a custom renderer, I wanna change the shape of every button in my app. Sounds easy, huh?
Setup:
Xamarin.Forms Version 2.3.2.127
Xamarin.Android.Support.* Version 23.3.0
My custom renderer:
var btn = this.Control as Android.Widget.Button;
btn.SetBackgroundResource(Resource.Drawable.arrow_button);
When I try to build & deploy it, the Error List gives me the following error:
CS0117 C# 'Resource' does not contain a definition for 'Drawable'
How can I resolve this error?
Cheers!
Upvotes: 4
Views: 9166
Reputation: 69
I sort ran into similar error. It might that you are missing
using Android.Graphics.Drawables;
and make sure that your drawables are in png format, because jpg-s dont work. if this doesnt help, ill delete my answer
Upvotes: -1
Reputation: 2666
You are using the wrong Resource namespace. I had to use Droid.Resource in my project like this:
btn.SetBackgroundResource(Droid.Resource.Drawable.arrow_button);
Otherwise Xamarin doesn't know which Resource you mean, so you got to name it explicitly.
Upvotes: 2
Reputation: 5817
What I usually do when this one surfaces...
Good luck. Healy in Tampa.
Upvotes: 1