Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This, move my TextBlock to left to rigth, but if I do my window larger, does not work. What Can I do? I have this code, it works for Windows FOrm, but in WPF it not
WPF C#

DoubleAnimation doubleAnimation = new DoubleAnimation();
doubleAnimation.From = this.ActualWidth;
doubleAnimation.To = this.ActualWidth;
doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
doubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(5));
marquee.BeginAnimation(Canvas.RightProperty, doubleAnimation);

XAML
XML
<Canvas>
<TextBlock Name="marquee" FontSize="30" Text="Sample Marquee" Canvas.Left="8" Canvas.Top="437" />
<Button Width="100" Height="50" Content="Marquee" Click="Button_Click" Canvas.Left="6" Canvas.Top="144" />
</Canvas>


A similar code that it work (For Windows Form) is:
C#
private void timer1_Tick(object sender, EventArgs e)
        {
            this.Refresh();

            myLabel2.Left += 15;

            if (myLabel2.Left >= this.Width)
            {
                myLabel2.Left = myLabel2.Width * -1;
            }
        }
Posted
Comments
Member 11706789 21-May-15 19:05pm    
Thanks -.-

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900