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:この値をリソースファイルの文字列で埋めることができれば、それは素晴らしいことです。どちらの方法でも役に立ちますが、後で1つを使用することをお勧めします。

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 に答える