Cs0117 c# “resource” does not contain the definition of “paintable”

After I finally managed to set up a custom renderer, I wanted to change the shape of each button in the application. That sounds easy, right?

set up:

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);

Invalid Sign

CS0117  C# 'Resource' does not contain a deFinition for 'Drawable'

How do I resolve this error?

Cheers!

resolvent:

You have used the wrong resource namespace. I must use droid.resource in my project like this:

btn.SetBackgroundResource(Droid.Resource.Drawable.arrow_button);

Otherwise, xamarin does not know which resource you are referring to, so it must be named explicitly

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>