【问题标题】:Moving Title or text in application metro在应用程序 Metro 中移动标题或文本
【发布时间】:2012-10-09 07:33:39
【问题描述】:

我需要在我的 Windows 8 应用程序中添加移动文本或移动标题。 我怎么能用 XAML 做到这一点? 这是一个 HTML 示例:http://www.astwinds.com/astuces/html/textedefilant.html

最好的问候

【问题讨论】:

  • />。希望这对您有所帮助。
  • 对不起,我需要一个移动的文本,我需要我的文本从左到右单独移动
  • 你的意思是类似于marquee的控件吗?
  • 是一个类似于 marquee 的控件
  • 谷歌帮助你。 codeproject sample

标签: c# wpf xaml windows-8 microsoft-metro


【解决方案1】:

这是一种方法。当然还有更多。

在 OnNavigatedTo 事件中的 Composition Target Rending 事件中添加对 MoveMarqueeText 函数的调用。

protected override void OnNavigatedTo(NavigationEventArgs e)
{
     CompositionTarget.Rendering += MoveMarqueeText;
}

添加一个函数,该函数将删除字符串的第一个字符并将其附加到末尾。

void MoveMarqueeText(object sender, object e)
{
     Marquee.Text = Marquee.Text.Substring(1)  + Marquee.Text.Substring(0,1);
}

使用 XAML

<TextBlock Text="woot hey woot woot hey woot hey woot woot hey woot hey woot woot hey" Width="250" x:Name="Marquee" TextWrapping="NoWrap">

要减慢它的速度,请在您的 MoveMarqueeText 函数中添加一个条件语句和一个计数器增量,以根据时间减慢它,在您的条件中使用一个计时器。

【讨论】:

  • 它可以工作,但效果不好。文字闪烁。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-21
  • 1970-01-01
  • 2012-08-10
  • 1970-01-01
相关资源
最近更新 更多