我在我的 Xamarin 表单项目中使用库“Stormlion.ShapeControl”(GitHub here)在 ListView 项中生成一个圆圈。
列表中的每个项目都需要为圆圈使用不同的填充颜色。
现在我正在使用代码
<shapes:Circle HeightRequest="20" WidthRequest="20">
<shapes:Circle.Paint>
<shapes:SSPaint x:Name="circleFillColor" FillColor="Orange"/>
</shapes:Circle.Paint>
</shapes:Circle>
效果很好,但是当我尝试使用以下代码绑定(bind)颜色时:
<shapes:Circle HeightRequest="20" WidthRequest="20">
<shapes:Circle.Paint>
<shapes:SSPaint x:Name="circleFillColor" FillColor="{Binding Path=Color}"/>
</shapes:Circle.Paint>
</shapes:Circle>
我得到错误:
No property, bindable property, or event found for 'FillColor', or mismatching type between value and property.
我也无法从后面的代码访问该属性(我假设它是 ListView 的一部分?)
如果有人能指出我正确的方向,那就太好了!
最佳答案
检查 the code SSPaint
对象。 FillColor
似乎不是可绑定(bind)的属性,因此您不能这样使用它。你必须给它一个静态颜色。
您可以创建自己的继承来解决这个问题和/或在请求此功能的 repo 上打开一个问题。似乎有人已经为 BorderColor
做了:https://github.com/stormlion227/ShapeControl.Forms/issues/1
关于c# - 将颜色动态绑定(bind)到 Xamarin Shape,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51892363/