如何在不使用自定义渲染器的情况下使用Xamarin Forms C#在中心绘制带有文本的圆? [英] How To Draw a circle with a text in the center using Xamarin Forms C# Without using custom-renderer?

查看:91
本文介绍了如何在不使用自定义渲染器的情况下使用Xamarin Forms C#在中心绘制带有文本的圆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是xamarin表单的新手,我必须绘制一个圆,标签位于圆的中心,标签的内容是动态的,因此它必须支持数据绑定,并且圆应适应于包含文本.

I am new to xamarin forms and I have to draw a Circle with label positioned at the center of the circle, the content of the label is dynamic, so it must support data binding and the circle should adapt to contains the text.

请注意:文字主要是数字,我不必支持两位以上的文字.

在以下问题中 圆形标签Xamarin表单

他们解释了如何使用自定义渲染器实现这一目标,但是,只要有我认为可以满足要求的NControl和NGraphics库,我认为这样的任务不需要客户渲染器的复杂性.

they explain how to achieve that using Custom renderer, however I don't feel like such a task needs the complexity of customer renderers as long as there are NControl and NGraphics Libraries that -I think- can satisfy the requirements.

能否请您指导我如何使用NGraphics和NControl库实现此类任务?

Could you please guide me on how to achieve such task using NGraphics and NControl Libraries?

推荐答案

如果您不想使用按钮,也可以使用框架.

If you don't want to use a button you can also use a frame.

<Frame HeightRequest="40" WidthRequest="40" CornerRadius="20" HorizontalOptions="Start" VerticalOptions="Start" Margin="0" Padding="0" BackgroundColor="Maroon">
    <Label Text="7" TextColor="White" HorizontalOptions="Center" VerticalOptions="Center" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" />
</Frame>

信用转到该论坛 https://forums .xamarin.com/discussion/99509/how-make-a-circle-label#Comment_322491

这篇关于如何在不使用自定义渲染器的情况下使用Xamarin Forms C#在中心绘制带有文本的圆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆