【问题标题】:Xamarin Forms complexe clickable labelXamarin Forms 复杂的可点击标签
【发布时间】:2017-08-17 05:31:13
【问题描述】:

我正在尝试创建一个包含经典作品和链接词的字符串。

我有这句话:

我接受使用条款隐私政策

在这句话中,我想让粗体字可以点击。

我已经尝试过使用Horizo​​ntal StackLayoutLabelsButtons,但结果不像一个简单的句子... p>

有什么想法吗?

【问题讨论】:

    标签: xamarin xamarin.forms


    【解决方案1】:

    在标签上使用TapGestureRecognizer

    var terms = new Label() { Text = "terms of use" };
    var termsTapped = new TapGestureRecognizer();
    termsTapped.Tapped += (o,e) =>
    {
        //do something
    };
    terms.GestureRecognizers.Add(termsTapped);
    
    var stack = new StackLayout()
    {
        Orientation = StackOrientation.Horizontal
    };
    stack.Children.Add(new Label() { Text = "I accept the " });
    stack.Children.Add(terms);
    

    ...您的隐私政策也是如此。

    编辑:
    如果您想在单个标签中使用此功能,您可以实现自己的 Span,它是可点击的并与 FormattedString 一起使用。

    【讨论】:

    • 好的。我会尝试使用多个标签。如果显示不正确,我将实现自己的跨度。
    • 这就是要走的路。 ;-) 如果我能提供帮助,请标记为答案。
    • 我在完成后测试实现标记作为答案:)
    猜你喜欢
    • 2016-12-19
    • 1970-01-01
    • 2017-06-05
    • 1970-01-01
    • 1970-01-01
    • 2020-07-15
    • 2013-08-13
    • 1970-01-01
    • 2021-12-06
    相关资源
    最近更新 更多