我有創建滾動的文字和我的主窗口的動畫我這樣稱呼它的用戶控件分離選取框:添加多個文本串到一個段落
xmlns:mar="clr-namespace:WpfApplication4.AppPages"
<mar:Feed Background="DarkGray" FontSize="12" MarqueeTimeInSeconds="8"
Foreground="Gray" Margin="7,383,711,6" MarqueeContent="Live Feed"
MarqueeType="TopToBottom"></mar:Feed>
用戶的代碼控制是這樣的:
MarqueeType _marqueeType;
public MarqueeType MarqueeType
{
get { return _marqueeType; }
set { _marqueeType = value; }
}
public String MarqueeContent
{
set { tbmarquee.Text = value; }
}
private double _marqueeTimeInSeconds;
public double MarqueeTimeInSeconds
{
get { return _marqueeTimeInSeconds; }
set { _marqueeTimeInSeconds = value; }
}
public Feed()
{
InitializeComponent();
canMain.Height = this.Height;
canMain.Width = this.Width;
this.Loaded += new RoutedEventHandler(Feed_Loaded);
}
void Feed_Loaded(object sender, RoutedEventArgs e)
{
StartMarqueeing(_marqueeType);
}
public void StartMarqueeing(MarqueeType marqueeType)
{
TopToBottomMarquee();
}
private void TopToBottomMarquee()
{
double width = canMain.ActualWidth - tbmarquee.ActualWidth;
tbmarquee.Margin = new Thickness(width/2, 0, 0, 0);
DoubleAnimation doubleAnimation = new DoubleAnimation();
doubleAnimation.From = -tbmarquee.ActualHeight;
doubleAnimation.To = canMain.ActualHeight;
doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
doubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(_marqueeTimeInSeconds));
tbmarquee.BeginAnimation(Canvas.TopProperty, doubleAnimation);
}
public enum MarqueeType
{
TopToBottom
}
在我設置像這樣的XAML MarqueeContent="Live Feed"
主窗口,但我怎麼能設置在後面的代碼內容,我怎麼可以設置多個MarqueeContents?
例如,即使我能夠從後面的代碼中設置MarqueeContent,並且我添加了多個項目,它無疑會像剛剛讀取的文本一樣依次添加它,因此我需要它如果有意義,我添加的項目至少有一個段落間距。
爲了給它一個視覺的想法,你可以看到它在這裏(自上而下):
http://www.codeproject.com/Articles/48267/Making-a-Simple-Marquee-Text-Control-Drip-Animatio
我需要它,所以我可以多串加載到其中。並且每個添加的文本字符串都用段落分隔。
但是你不想讓這些項目獨立地進行動畫,只需要在行之間有段落間距的文本移動塊? – Clemens 2012-04-21 07:59:04