I have a user control which creates an animation of scrolling text and on my main window I call it like this:
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>
The code for the user control looks like this:
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
}
On the main window I set the xaml MarqueeContent="Live Feed" like so but how can I set the content in the code behind and how can I set multiple MarqueeContents?
For instance even if I was able to set the MarqueeContent from code behind and I added multiple items to it, it will no doubt just add it one after the other like the text your reading just now, I need it so each item I add has at least a paragraph spacing if that makes sense.
To give a visual idea on it you can see it here (TopDown):
http://www.codeproject.com/Articles/48267/Making-a-Simple-Marquee-Text-Control-Drip-Animatio
I need it so I can load multiple strings into it. And that each string of text added is separated by a paragraph.
If it is only about adding multiple lines of text to one moving block, you could simply add line breaks between the lines:
Or you can do the same with Inlines: