Powertoys, WPF and MVVM - Printable Version
+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: Ab3d.PowerToys (https://forum.ab4d.com/forumdisplay.php?fid=9)
+--- Thread: Powertoys, WPF and MVVM (/showthread.php?tid=4139)
Powertoys, WPF and MVVM - Pioter - 07-11-2019
I consider Powertoys as drawing engine embedded in 3d modeling software about to create.
I wonder how MVVM friendly PowerToys are?
Ploting sphere is as easy as having
then let imagine I have collection of spheres dynamically added by users, so my ViewModel owns property encapsulating list of sphere's descriptors (ie size and location):
where SphereDescriptor class is shaped like below:
and finally i'd like to have view defined like that:
Please notice Binding definition instead explicitly given values.
So how MVVM friendly PowerToys are?
RE: Powertoys, WPF and MVVM - abenedik - 07-12-2019
All the Visual3D classes (SphereVisual3D, BoxVisual3D, ...) are standard WPF DependencyObjects with most properties implemented as DependencyProperties so they can be data binded - for example sphere's Radius, Position and Material can be data binded. But many values cannot be simply changed with binding - for example if you want to change individual positions or some other "raw" properties you will need to access them directly.
Also it is not possible to dynamically add multiple objects to the scene - you cannot use ItemList inside Viewport3D. You can theoretically derived from ModelVisual3D and add some support for dynamic Items or ItemsSource property, but you would need to code the logic in this class.
I am not an expert for MVVM but still I think that WPF 3D and Ab3d.PowerToys are not very well suited for MVVM. Especially when the applications's performance is important and 3D scene becomes more complex.