首页 文章

当动态更改背景时,Xamarin Custom Frame会导致Java.Lang.NullPointerException

提问于
浏览
5

我有一个Xamarin表单框架的自定义渲染器:CustomFrameRenderer . Xaml示例如下

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

问题是,如果我将bacground颜色绑定到这样的属性,

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

框架根据ListView中选择的项目更新颜色 . 现在,如果我使用标准框架,它可以完美地运行 . 但是我使用带圆角的自定义框架,我在Android中遇到此错误 .

Java.Lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isMutable()' on a null object reference

任何帮助表示赞赏 .

1 回答

相关问题