2
我使用下面的動畫(從右到左滾動字幕)代碼: -權在WPF文本的左跑馬燈,其中文本塊的寬度大於窗口無閃爍
private void RightToLeftMarquee(TextBlock tb)
{
doubleAnimation = new DoubleAnimation();
doubleAnimation.From = -tb.Width;
doubleAnimation.To = TickerCanvas.Width;
doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
doubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(100));
Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(Canvas.Right)"));
sb.Children.Add(doubleAnimation);
sb.Begin(tb,true);
}
此代碼移動文本塊罰款當textblock的寬度小於canvas時,但是當textblock寬度大於canvas寬度時,選取框會閃爍。
hi Eli Arbel。感謝您的回答。我想知道如何在wpf中設置TextFormattingMode,因爲我無法找到TextOptions的上述屬性。 – Gaurang
您正在使用哪個版本的.NET? –
我正在使用.Net 4.5 – Gaurang