如何将文本包装到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
最满意答案
在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 tofloat
then the output isfloat
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- ...
-
摘要()舍入(summary() rounding)[2023-07-19]
如果将显示精度设置为足够的数字,则此方法有效: 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 ... -
舍入变量(Rounding of variables)[2022-12-03]
在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 ...
-
从C#调用Delphi 6 DLL导致不同的舍入?(Calling Delphi 6 DLL from a C# results in different rounding?)[2022-07-18]
1.9在浮点中不能完全表示,而225是完全可表示的。 目前尚不清楚输入数字的来源,但IEEE754算法根本不可能完全执行产品1.9 * 225。 您看到的行为与舍入无关,实际上是关于可表示性的。 如果您需要完全执行此计算,则需要使用十进制算术而不是浮点。 这意味着在Delphi中使用货币类型或在C#中使用十进制。 您的不同行为的来源可能低至控制浮点寄存器的8087控制字。 当您的DLL执行时,从C#调用,控制字将与默认的Delphi设置不同。 在DLL的入口点调用Set8087CW($ 1372)以使用默认 ... -
防止舍入错误(Preventing Rounding Errors)[2023-12-01]
强制性讲座: 每位程序员应了解浮点运算 。 另外,请尝试阅读IEEE浮点标准 。 你总会遇到舍入错误。 除非你使用 无穷 任意精度库,如gmplib 。 你必须决定你的应用程序是否真的需要这种努力。 或者,您可以使用整数算术,只在需要时才转换为浮点数。 这仍然很难做,你必须决定是否值得。 最后,您可以使用float或double精度值,以避免在表示精度极限的情况下对值进行假设。 我希望这个Valgrind插件已经实现(grep for float)... Obligatory lecture: What E ... -
MSDN对VBA中的Round()函数有这样的说法: 尽管Round函数对于返回具有指定小数位数的数字很有用,但是当舍入数字为5时,无法始终预测它将如何舍入.VBA如何舍入数字取决于该数字的内部二进制表示。 关于VBScript并没有说同样的事情,但我冒昧地猜测同样的事情正在发生。 最重要的是,如果你想要一个实际上可预测的Round()函数,你必须自己编写。 :/ (如果你想要一个执行“正常”舍入的函数,而不是一些花哨的“舍入到偶数”公式,请使用FormatNumber()。据我所知,那个实际上表现得可预测 ...
-
帮助舍入部门(Help Rounding division)[2023-11-23]
对数字进行舍入后,您可以选择将其存储为integer或long integer 。 您可以选择将其存储为浮点类型,例如float或double但是如您所知它没有小数部分,读者可能会更清楚地看到它表示为整数类型。 要记住的一点是,浮点数能够不精确地存储非常大的数字,这些数字可能不适合常规int或甚至long类型。 最大的长期是9,223,372,036,854,775,807而最大的double是1.7976931348623157 × 10³⁰⁸ 。 然而,错误是令人困惑的,因为它应该明显地调用double ... -
JAVA - 全球数字舍入(JAVA - Global Number Rounding)[2024-01-13]
我担心你所尝试的是不可行的。 即使设置默认语言环境也无济于事。 你想要一种设置全局格式的方法,但底线是你将不得不调用某种格式(例如使用NumberFormat实现)。 你可以做的是创建一个全局访问的静态函数,你将在任何需要的地方使用它。 不是最好的方法,但无论如何都有效 (正如伍迪艾伦所说)。 I am afraid that what you are trying is not doable. Even setting the default locale will not help here. You ... -
红宝石中的舍入数字(Rounding numbers in ruby)[2023-03-14]
使用圆形方法。 它需要一个整数参数,指定要舍入的小数位数。 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 ...