首页 \ 问答 \ 如何将文本包装到TextBlock中?(How can I wrap text in a TextBlock?)

如何将文本包装到TextBlock中?(How can I wrap text in a TextBlock?)

我是windows phone7开发的新手,并且有一个小问题。

我的界面中有一个文本块(标签),在运行时我使用该标签来显示浮动数据。 问题是文本太长(比屏幕宽度)时,它只显示一半的数据(只有符合宽度的内容)。 去多行并不重要,但我想显示完整的内容。 我测试了Textblock(Label)属性,但没有找到任何工作。

有人可以帮帮我吗。 (我正在使用visual studio 2010)。 谢谢


以下是XAML

<Grid x:Name="LayoutRoot" Height="98">
    <Ellipse Height="25" HorizontalAlignment="Left" Name="ellipse1" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="46" Margin="6,13,0,0" Fill="#FFDB4C4C" />
    <TextBlock Height="30" HorizontalAlignment="Left" Margin="66,10,0,0" Name="textBlock1" Text="TextBlock" VerticalAlignment="Top" Width="402" AllowDrop="False" TextWrapping="NoWrap" UseLayoutRounding="True" DataContext="{Binding}" />
    <TextBlock Height="30" HorizontalAlignment="Left" Margin="66,44,0,0" Name="textBlock2" Text="TextBlock" VerticalAlignment="Top" Width="402" />
</Grid>

I am new to windows phone7 development and have a little issue.

I have a textblock(Label) in my interface, and in runtime I use that label to display dyanamic data. The problem is when the text is too long(than the width of the screen), it only displays half of the data(Only the content that fits the width). It doesn't matter to go for multiple lines, but I want to display the full content. I tested with Textblock(Label) properties, but didn't find any working.

Can someone please help me. (I am Using visual studio 2010) . Thanks


Following is the XAML

<Grid x:Name="LayoutRoot" Height="98">
    <Ellipse Height="25" HorizontalAlignment="Left" Name="ellipse1" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="46" Margin="6,13,0,0" Fill="#FFDB4C4C" />
    <TextBlock Height="30" HorizontalAlignment="Left" Margin="66,10,0,0" Name="textBlock1" Text="TextBlock" VerticalAlignment="Top" Width="402" AllowDrop="False" TextWrapping="NoWrap" UseLayoutRounding="True" DataContext="{Binding}" />
    <TextBlock Height="30" HorizontalAlignment="Left" Margin="66,44,0,0" Name="textBlock2" Text="TextBlock" VerticalAlignment="Top" Width="402" />
</Grid>

原文:https://stackoverflow.com/questions/8151397
更新时间:2024-05-17 17:05

最满意答案

在python2.x中, integer division总是导致截断输出,但如果其中一个操作数更改为float则输出也是float

In [40]: 4200/820
Out[40]: 5

In [41]: 4200/820.0
Out[41]: 5.121951219512195

In [42]: 4200/float(820)
Out[42]: 5.121951219512195

这已在python 3.x中更改 ,在py3x中/导致True划分(非截断),而//用于截断输出。

In [43]: from __future__ import division #import py3x's division in py2x

In [44]: 4200/820
Out[44]: 5.121951219512195

In python2.x integer division always results in truncated output, but if one of the operand is changed to float then the output is float too.

In [40]: 4200/820
Out[40]: 5

In [41]: 4200/820.0
Out[41]: 5.121951219512195

In [42]: 4200/float(820)
Out[42]: 5.121951219512195

This has been changed in python 3.x, in py3x / results in True division(non-truncating) while // is used for truncated output.

In [43]: from __future__ import division #import py3x's division in py2x

In [44]: 4200/820
Out[44]: 5.121951219512195

相关问答

更多
  • 使用Math.Round并指定小数位数。 Math.Round(pay,2); Math.Round方法(Double,Int32) 将双精度浮点值舍入为指定的小数位数。 或Math.Round方法(十进制,Int32) 将十进制值舍入到指定的小数位数。 Use Math.Round and specify the number of decimal places. Math.Round(pay,2); Math.Round Method (Double, Int32) Rounds a double- ...
  • 如果将显示精度设置为足够的数字,则此方法有效: options(digits=10) summary(1:1283932) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.0 320983.8 641966.5 641966.5 962949.2 1283932.0 This works if you set your display precision to enough digits: options(digits=10 ...
  • 在python2.x中, integer division总是导致截断输出,但如果其中一个操作数更改为float则输出也是float 。 In [40]: 4200/820 Out[40]: 5 In [41]: 4200/820.0 Out[41]: 5.121951219512195 In [42]: 4200/float(820) Out[42]: 5.121951219512195 这已在python 3.x中更改 ,在py3x中/导致True划分(非截断),而//用于截断输出。 In [43 ...
  • 我添加了一个正则表达式函数并使用了JavaScript Math.Round函数。 下面是在你的jsfiddle中测试的一个工作示例: $.fn.digits = function(){ return this.each(function(){ $(this).text( $(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") ); }) } $("#value,#growth").change(functi ...
  • 1.9在浮点中不能完全表示,而225是完全可表示的。 目前尚不清楚输入数字的来源,但IEEE754算法根本不可能完全执行产品1.9 * 225。 您看到的行为与舍入无关,实际上是关于可表示性的。 如果您需要完全执行此计算,则需要使用十进制算术而不是浮点。 这意味着在Delphi中使用货币类型或在C#中使用十进制。 您的不同行为的来源可能低至控制浮点寄存器的8087控制字。 当您的DLL执行时,从C#调用,控制字将与默认的Delphi设置不同。 在DLL的入口点调用Set8087CW($ 1372)以使用默认 ...
  • 强制性讲座: 每位程序员应了解浮点运算 。 另外,请尝试阅读IEEE浮点标准 。 你总会遇到舍入错误。 除非你使用 无穷 任意精度库,如gmplib 。 你必须决定你的应用程序是否真的需要这种努力。 或者,您可以使用整数算术,只在需要时才转换为浮点数。 这仍然很难做,你必须决定是否值得。 最后,您可以使用float或double精度值,以避免在表示精度极限的情况下对值进行假设。 我希望这个Valgrind插件已经实现(grep for float)... Obligatory lecture: What E ...
  • MSDN对VBA中的Round()函数有这样的说法: 尽管Round函数对于返回具有指定小数位数的数字很有用,但是当舍入数字为5时,无法始终预测它将如何舍入.VBA如何舍入数字取决于该数字的内部二进制表示。 关于VBScript并没有说同样的事情,但我冒昧地猜测同样的事情正在发生。 最重要的是,如果你想要一个实际上可预测的Round()函数,你必须自己编写。 :/ (如果你想要一个执行“正常”舍入的函数,而不是一些花哨的“舍入到偶数”公式,请使用FormatNumber()。据我所知,那个实际上表现得可预测 ...
  • 对数字进行舍入后,您可以选择将其存储为integer或long integer 。 您可以选择将其存储为浮点类型,例如float或double但是如您所知它没有小数部分,读者可能会更清楚地看到它表示为整数类型。 要记住的一点是,浮点数能够不精确地存储非常大的数字,这些数字可能不适合常规int或甚至long类型。 最大的长期是9,223,372,036,854,775,807而最大的double是1.7976931348623157 × 10³⁰⁸ 。 然而,错误是令人困惑的,因为它应该明显地调用double ...
  • 我担心你所尝试的是不可行的。 即使设置默认语言环境也无济于事。 你想要一种设置全局格式的方法,但底线是你将不得不调用某种格式(例如使用NumberFormat实现)。 你可以做的是创建一个全局访问的静态函数,你将在任何需要的地方使用它。 不是最好的方法,但无论如何都有效 (正如伍迪艾伦所说)。 I am afraid that what you are trying is not doable. Even setting the default locale will not help here. You ...
  • 使用圆形方法。 它需要一个整数参数,指定要舍入的小数位数。 NUMBER_OF_DECIMAL_PLACES_TO_ROUND_TO = 1 rounded_mean = your_calculated_mean.round(NUMBER_OF_DECIMAL_PLACES_TO_ROUND_TO) 查看有关Ruby中的舍入数字的这篇文章 Use the round method. It takes an integer parameter specifying the number of dec ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)