1

I am trying to achieve something very similar to this:

WPF with Helix toolkit, animate with code-behind?

However, my scenarios is slightly different. I am trying to animate a tube (curve) defined by a path (TubePath) which undergoes deformation as a function of time (animation) defined by a mathematical function (calculated numerically).

My design/plan is to use a usercontrol (containing the Helix Tube control) to draw each frame of the tube defined by a path. I plan to make the TubePath property in my usercontrol which is an oservablecollection a dependency property. I plan to control the animation from my ViewModel (or View) by binding the CurrentPath property of the ViewModel to the usercobtrol TubePath property. I plan to drive my ViewModel from INotifyPropertyChanged. I will a have List of Paths (PathList) stored in advance of starting the animation in my Model. At each (so called) time or animation step, I will copy the corresponding path from the PathList to the CurrentPath in the VieModel. I am hoping that change in the the CurrentPath collection in the ViewModel will activate the binding which will force the user control to update the tube drawn by the usercontrol.

These are my questions:

(1) I have read that not all changes to an ObservableCollection fires propertychanged events. Will overwriting or refereshing the whole CurrentPath collection in the ViewModel update the TubePath in the UserControl which will force redrawing of the tune? Do I have to do anything special to achieve this kind of binding.

(2) I am new to WPF and animations with WPF. My research indicated that I could do the animation from my ViewModel in several ways: using the Dispatcher.Invoke() like in the example given above, or I could use the RenderingEventManager.AddListener() (and RenderingEventManager.RemoveListener() to stop animation) provided by the Helix Toolkit like it is done in example here:

https://github.com/helix-toolkit/helix-toolkit/tree/develop/Source/Examples/WPF/ExampleBrowser/Examples/Wind

or I could loop using DispatcherTimer() as done here:

Binding on DependencyProperty of custom User Control not updating on change

Any suggestions as to the best method as well as my concept of driving animation from the ViewModel would be greatly appreciated.

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
I. Konuk
  • 59
  • 8
  • I have a feeling this question is at risk of getting closed as too broad - I would recommend asking your questions 1 & 2 as two separate posts here. Its OK if you have to copy a lot of the intro text into the second question. And you can link between them if that is helpful. – StayOnTarget Sep 11 '20 at 12:52
  • Solution to the first question can now be found in: [Pass a ObservableCollection to UserControl](https://stackoverflow.com/questions/64144614/pass-a-observablecollectionobject-to-usercontrol) – I. Konuk Sep 30 '20 at 23:56

0 Answers0