2013-01-15 40 views
0

换行符要将新行字符如何设置文本,包括故事板

<VisualState x:Name="Snapped"> 
    <Storyboard> 
     <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Text" Storyboard.TargetName="textBlock"> 
      <DiscreteObjectKeyFrame KeyTime="0" Value="Here is my text.\nThis is new line"/> 
    </Storyboard> 
</VisualState> 

输出文本,以取代“\ n”:Here is my text.\nThis is new line
无需换行字符。

评论:如果这个值可以用资源文件中的字符串填充,那将是一个很好的.. !! 无论哪种方式会帮助我,但后来一个是不错的办法。

+0

阅读本? http://stackoverflow.com/questions/183406/xaml-newline-in-string-attribute –

回答

2

没问题......

Value="Here is my text.&#10;This is new line" 

希望这有助于。

+0

有没有一种方法来设置从资源文件中像'X此值:Uid'? –

+0

你只是想存储一个字符串和应用像'值=“{StaticResource的BlahText}”'呢?确保我理解哈哈。 –

+0

文本存储在'.resw'文件中,而不是标准资源 –

1

这工作:

<TextBlock FontSize="20"> 

    <TextBlock.Resources> 
     <Storyboard x:Name="MyStory"> 
      <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MyLine1" 
        Storyboard.TargetProperty="Text"> 
       <DiscreteObjectKeyFrame KeyTime="0" Value="New Line 1" /> 
      </ObjectAnimationUsingKeyFrames> 
      <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MyLine2" 
        Storyboard.TargetProperty="Text"> 
       <DiscreteObjectKeyFrame KeyTime="0" Value="New Line 2" /> 
      </ObjectAnimationUsingKeyFrames> 
     </Storyboard> 
    </TextBlock.Resources> 

    <TextBlock.Inlines> 
     <Run x:Name="MyLine1" Text="Original Line 1" /> 
     <LineBreak /> 
     <Run x:Name="MyLine2" Text="Original Line 2" /> 
    </TextBlock.Inlines> 

</TextBlock> 

你也可以尝试这样的事情没有LineBreak

<DiscreteObjectKeyFrame KeyTime="0" Value="New Line 1&#x0a;" /> 
相关问题