积极答复者
(WP8.1)textbox文字超出显示区域如何自动滚动显示?

问题
答案
-
您好,
这种效果可以考虑用动画去实现,你需要借助外层容器,比如canvas。
我的例子是用TextBlock实现的,你可以尝试用TextBox:
<Page.Resources> <Storyboard x:Name="Storyboard2" RepeatBehavior="Forever"> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="marquee"> <EasingDoubleKeyFrame KeyTime="0" Value="0"/> <EasingDoubleKeyFrame KeyTime="0:0:3" Value="-370"/> <EasingDoubleKeyFrame KeyTime="0:0:6" Value="-13.75"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </Page.Resources> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Canvas Width="150" > <TextBlock Name="marquee" Text="Sample Marquee abcdefghijklmnopqrst" RenderTransformOrigin="0.5,0.5" > <TextBlock.RenderTransform> <CompositeTransform/> </TextBlock.RenderTransform> </TextBlock> <Button Width="100" Height="50" Content="Marquee" Click="Button_Click" Canvas.Left="168" Canvas.Top="168" /> </Canvas> </Grid>
private void Button_Click(object sender, RoutedEventArgs e) { Storyboard2.Begin(); }
另外一种,你可以考虑传统的C#编程方式去实现,可以借助Dispatcher.Timer类定时去移动文本框中的字符。
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- 已建议为答案 Xavier Xie-MSFT 2016年3月1日 2:07
- 已标记为答案 learn WP 2016年4月13日 14:46
2016年2月24日 6:56
全部回复
-
您好,
>>"让其自动滚动显示超出区域的文字"
我不是很明白你的意思,你是想让超出部分的文字自动换行显示,还是其他的什么效果,还请描述清楚。
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.2016年2月23日 8:05 -
您好,
这种效果可以考虑用动画去实现,你需要借助外层容器,比如canvas。
我的例子是用TextBlock实现的,你可以尝试用TextBox:
<Page.Resources> <Storyboard x:Name="Storyboard2" RepeatBehavior="Forever"> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="marquee"> <EasingDoubleKeyFrame KeyTime="0" Value="0"/> <EasingDoubleKeyFrame KeyTime="0:0:3" Value="-370"/> <EasingDoubleKeyFrame KeyTime="0:0:6" Value="-13.75"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </Page.Resources> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Canvas Width="150" > <TextBlock Name="marquee" Text="Sample Marquee abcdefghijklmnopqrst" RenderTransformOrigin="0.5,0.5" > <TextBlock.RenderTransform> <CompositeTransform/> </TextBlock.RenderTransform> </TextBlock> <Button Width="100" Height="50" Content="Marquee" Click="Button_Click" Canvas.Left="168" Canvas.Top="168" /> </Canvas> </Grid>
private void Button_Click(object sender, RoutedEventArgs e) { Storyboard2.Begin(); }
另外一种,你可以考虑传统的C#编程方式去实现,可以借助Dispatcher.Timer类定时去移动文本框中的字符。
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- 已建议为答案 Xavier Xie-MSFT 2016年3月1日 2:07
- 已标记为答案 learn WP 2016年4月13日 14:46
2016年2月24日 6:56