Windows 8 如何在故事板中设置包含新行字符的文本
要用新行字符替换“\n”Windows 8 如何在故事板中设置包含新行字符的文本,windows-8,winrt-xaml,windows-store-apps,Windows 8,Winrt Xaml,Windows Store Apps,要用新行字符替换“\n” <VisualState x:Name="Snapped"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Text" Storyboard.TargetName="textBlock"> <DiscreteObjectKeyFrame KeyTime="0" Value="Here i
<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这是新行
没有新行字符 p.S.:若这个值可以用资源文件中的字符串填充,那个将是一个很棒的。。!! 任何一种方法都能帮我解决问题,但以后有一种方法是很好的。当然
Value="Here is my text. This is new line"
希望这有帮助。当然
Value="Here is my text. This is new line"
希望这能有所帮助。这很有效:
<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>
这项工作:
<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>
有没有一种方法可以从资源文件中设置这个值,比如
x:Uid
?您只需要存储一个字符串,然后像value=“{StaticResource BlahText}”
那样应用它?确保我理解lol。文本存储在.resw
文件中,而不是标准资源中。那么,您是否只是在寻找类似“是”的内容。。我知道如何设置x:Uid
,但不知道如何在故事板中设置。有没有办法从资源文件(如x:Uid
)中设置此值?您只需要存储一个字符串并应用value=“{StaticResource BlahText}”
?确保我理解lol。文本存储在.resw
文件中,而不是标准资源中。那么,您是否只是在寻找类似“是”的内容。。我知道如何设置x:Uid
,但不知道如何在故事板中设置阅读此内容?读这个?