Xamarin Custom Frame throws Java.Lang.NullPointerException on background dynamic change

I have my own renderer for Xamarin Forms Frame: CustomFrameRenderer . Xaml example below

<controls:ExtendedFrame Margin="2,0,2,0" BackgroundColor="Red" HorizontalOptions="FillAndExpand" OutlineColor="Red" Padding="0,0,0,0"> <Label Text="This is a test"/> </controls:ExtendedFrame> 

The problem is that if I bind the bacground color to a property like this,

  <controls:ExtendedFrame Margin="2,0,2,0" BackgroundColor="{Binding FrameBackground}" HorizontalOptions="FillAndExpand" OutlineColor="{Binding FrameBackground}" Padding="0,0,0,0"> 

The frame updates its color based on the item selected in the ListView. Now, if I use a standard frame, it works fine. But I use my own rounded frame, I get this error in Android.

Java.Lang.NullPointerException: attempt to call the virtual method 'boolean android.graphics.Bitmap.isMutable ()' to reference a null object

Any help is appreciated.

+5
source share
1 answer

Even I had the same problem with managing the frame, in my case this problem was solved by changing the base class of my Android project rendering project for "Visual Element" like "Frame" instead of "Xamarin.Forms.Platform.Android" .FrameRenderer ". For more details, see updating my blog http://www.appliedcodelog.com/2017/12/bug-javalangnullpointerexceptionattemptempt.html

0
source

Source: https://habr.com/ru/post/1260798/


All Articles