c# - 标签中的装饰和扩展文本

标签 c# xaml xamarin xamarin.forms

是否可以在 Xamarin.Forms 标签小部件中使用粗体和非粗体文本?标签内是否也可以有端线?

<Label Text="Abc <b>def</b>"/>
<Label Text="Abc \ndef"/>

最佳答案

最好的方法是像这样绑定(bind) FormattedText 样式:

<Label FormattedText="{Binding CustomFormattedText}" />

在模型中:

    public FormattedString CustomFormattedText
    {
        get
        {
            return new FormattedString
            {
                Spans = {
                    new Span { Text = Sum, FontAttributes=FontAttributes.Italic, FontSize="10" },
                    new Span { Text = Info, FontSize="10" } }
            };
        }
        set { }
    }

关于c# - 标签中的装饰和扩展文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30610210/

相关文章:

.net - XAML 中的 WPF 本地化,什么是简单、简单和优雅的方法?

xamarin - 如何防止键盘打开时背景图像被挤压?

c# - Xamarin 表单按钮在 iOS 上带有文本和矢量图像

C# 漂亮的代码打印库

C# Silverlight 移动一个控件

c# - 不止一种控件类型的 WPF StackPanel.Resources setter ?

c# - 将 Base64 图像发送到服务器,然后从服务器拉取以稍后显示 Xamarin

c# - 我应该使用静态类来存储数据吗?

c# - FluentValidation 检查子集合中的重复实体

c# - 带有用户添加字段的 .net 文本框