I found Silverlight dashboard demo that works great @ http://blog.allaboutprogress.com/2010/04/silverlight-dashboards-part-i/
However, I want to get the application to work in WPF. I Created the Project in Silverlight and got it to run, then copied over the files into a WPF Application.
After a minor tweak I got it working, basically the same way, but the animation looks terrible compared to the Silverlight version.
1) In silverlight everything moves around smoothly no matter how large the form. In WPF animation gets erratic when there is to much animation going on, and also tends to perform worse the larger the containing window.
2) In Silverlight the both the pod that is being dragged and the other pods that need to get ot of the way animate smoothly. In wpf, the pod being moved does not move while you drag the mouse, but the other pods still get out of the way as you drag the mouse around. Then when you relase the mouse, the pod quickly move to the location you realeased the mouse at. Plus it doesn't take long for the other pods' animation to start looking bad (like the graphics driver is overwhelmed).
Why is the behavior so radically different for the same xaml and code between wpf and silverlight, and how can I get WPF to animate the same beautiful way the original Silverlight code does?
Here's the change I had to make to get the WPF version to work.
So first I created everything the way they did it on the Silverlight and it gave me an error when I first started it:
{"'System.Windows.Media.Animation.DoubleAnimation' cannot use default origin value of 'NaN'."}
So, I fixed that by updating the method,
void TranslateAnimation(UIElement element, double newLeft, double newTop, double ts)
with follwoing code at the start of the method:
void TranslateAnimation(UIElement element, double newLeft, double newTop, double ts)
{
if (double.IsNaN(Canvas.GetLeft(element)))
{
element.SetValue(Canvas.LeftProperty, Convert.ToDouble(0));
}
if (double.IsNaN(Canvas.GetTop(element)))
{
element.SetValue(Canvas.TopProperty, Convert.ToDouble(0));
}
...
This made it so the code would start/run without crashing.
This method creates the Storyboard and Double animation object, hooks it up with a pod, and then tells the storyboard to begin. It is called in a loop, once for each of the moving pods that that isn't currently being dragged by the mouse.