How would you make a line slowly draw across the screen?
I am trying to animate a line on a canvas in a C#/WPF project.
I would like to use C# code and not XAML.
How would you make a line slowly draw across the screen?
I am trying to animate a line on a canvas in a C#/WPF project.
I would like to use C# code and not XAML.
You will need to use a
Storyboard
and animate theLine.X2
andLine.Y2
Properties. See if this works for you.MainWindow.xaml
Button Click Event
I Have a running sample that uses the MVVM Pattern and creates Lines within a
ListBox
that has aCanvas
as itsItemsPanel
.I actually made it for this question, but the OP kind of dissapeared and never contacted me about it.
This is what it looks like in my computer:
The main part of it is this:
ViewModel:
Edit: Source code now on GitHub