```
public class MyImageView : ImageView
{
...
public override void SetImageResource(int resId)
{
var inputBitmap = ProcessImage(ContextCompat.GetDrawable(getContext(), resId));
}
...
}
```
在编译期间获取错误:
Controls/MyImageView.cs(...): error CS0103: The name 'getContext' does not exist in the current context
我做错了什么?
答案 0 :(得分:1)
Xamarin / C#规范化将是一个名为Context
的只读属性
public override void SetImageResource(int resId)
{
var inputBitmap = ProcessImage(ContextCompat.GetDrawable(Context, resId));
}