0

想用换行符替换“\n”

<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>

输出文本是:没有换行符。Here is my text.\nThis is new line

PS:如果这个值可以用资源文件中的字符串填充就好了..!! 无论哪种方式都会帮助我,但后来一种是好方法。

4

2 回答 2

2

确定的事...

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

希望这可以帮助。

于 2013-01-15T17:33:55.860 回答
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;" />
于 2013-01-16T15:19:39.697 回答