2015-12-14 60 views
0

我有以下幾點:換行不工作

<sys:String x:Key="NoDeviceAlert" xml:space="preserve">Your device is currently disabled.&#10;&#13;Please ensure it is turned on and connected.</sys:String> 

但是它不工作。 TextBlock的:

<TextBlock Text="{DynamicResource NoDeviceAlert}" Style="{DynamicResource msgTextStyle}" HorizontalAlignment="Center" /> 

保持在同一行兩個句子,但是移除十進制值。我也嘗試過十六進制值以及/ r/n。

這怎麼能工作?

UPDATE

<Style x:Key="msgTextStyle" TargetType="TextBlock"> 
    <Setter Property="Foreground" Value="#FFC8DBE7" /> 
    <Setter Property="FontFamily" Value="/Project;component/Utilities/Resources/Fonts/frutiger.ttf#Frutiger Linotype" /> 
    <Setter Property="FontSize" Value="20" /> 
    <Setter Property="TextAlignment" Value="Left" /> 
</Style> 

ResourceDictionary的SYS命名空間:

xmlns:sys="clr-namespace:System;assembly=mscorlib" 

的應用是Windows桌面,並使用.NET 4.5。

回答

0

屬性xml:space="preserve"僅影響XML解析器的工作。所以換行符,製表符和空格將保持不變。 而是輸入明確新行字符的只是按ENTER鍵:

<sys:String x:Key="NoDeviceAlert" xml:space="preserve">Your device is currently disabled. 
Please ensure it is turned on and connected.</sys:String> 
+0

它仍然在一條線上......甚至將它分成單獨的行使得句點在P字符旁邊。 – bl4kh4k

+0

不,它適用於我。可能是樣式'msgTextStyle'做了一些更改。請在帖子中提供。 –

+0

我在帖子中添加了樣式。 – bl4kh4k

0

您可以嘗試使用

& #X 0A;

像一個換行符(沒有這個空間裏面)。 它應該是工作。

+0

假設是x和0之間的空格嗎? – bl4kh4k