将断线符号绑定到Label.Text [英] Bind breakline symbol to Label.Text

查看:127
本文介绍了将断线符号绑定到Label.Text的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

绑定Label.Text时 尝试了很多方法: \ n \ r 但它们都没有显示为断线 我拒绝相信我将需要动态创建一个Custom控件来生成多个断线符号的跨度... 有没有更简单的方法?

When binding a Label.Text have tried many ways: \n \r but none of them are being displayed as breakline I refuse to believe I will need to dynamically create a Custom control to generate spans on numbers of breakline symbol... is there any easier/simpler approach ?

我尝试过的事情:

What I've tried:

  • string BreaklineText =文本第一行\ nText第二行"
  • string BreaklineText =文本第一行\ rText第二行"
  • 字符串BreaklineText = @文本第一行
文本第二行"
  • 字符串BreaklineText = @文本第一行
文本第二行"
  • string BreaklineText = "Text first line\nText second line"
  • string BreaklineText = "Text first line\rText second line"
  • string BreaklineText = @"Text first line 
 Text second line"
  • string BreaklineText = @"Text first line
Text second line"

xaml: <Label Text="{Binding BreaklineText}"/>

它应该在我的视图中显示为 文字第一行 文字第二行

It should be displayed on my view as Text first line Text second line

推荐答案

这不是最佳解决方案,因为我想找到一个可以在XAML上解释为BreakLine的符号,但它可以完成工作.

It's not the optimal solution since I wanted to find a symbol that could be interpreted as BreakLine on XAML, but it will do the job.

string BreaklineText = "Text first line\nText second line".Replace("\n", System.Environment.NewLine);

这篇关于将断线符号绑定到Label.Text的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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