首页 > 解决方案 > 如何在文本属性中放置不同的文本格式和超链接

问题描述

我想在我的 xamarin.forms 项目中使用 syncfusion 复选框,并且 text 属性应包含单个单词块上的超链接,该超链接应如下划线:

[ ] 继续注册帐户即表示您同意“条款和条件”

词块“条款和条件”应带有超链接下划线。

复选框的 XAML 如下所示:

<SfCheckBox x:Name="checkBoxIsAgreed" Text="text here"/>

如何仅使用作为字符串的文本属性来实现此目的?

提前致谢!

标签: c#xamlxamarinxamarin.forms

解决方案


更好的是,您可以将文本和复选框分开,如下所示。

    <StackLayout Orientation="Vertical">
        <SfCheckBox Text="text here"/>
        <Label>
            <Label.FormattedText>
                <FormattedString>
                    <Span Text="Text Here" />
                    <Span Text="Terms and Conditions" TextDecorations="Underline">
                        <Span.GestureRecognizers>
                            <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
                        </Span.GestureRecognizers>
                    </Span>
                </FormattedString>
            </Label.FormattedText>
        </Label>
    </StackLayout>

推荐阅读