Powertoys, WPF and MVVM

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

<visuals:SphereVisual3D CenterPosition="30 10 0" Radius="10" Material="s:64;Silver"/>
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):
public ObservableCollection<SphereDescriptor> Spheres => _spheres;

where SphereDescriptor class is shaped like below:

class SphereDescriptor
  public LocationXYZ Position { get; } // don't know exact Sphere.CenterPostion's type
  public int Radius { get; }
and finally i'd like to have view defined like that:
<List ItemsSource={Binding Spheres}>
           <visuals:SphereVisual3D CenterPosition="{Binding Position}" Radius="{Binding Radius}" Material="s:64;Silver"/>
 Please notice Binding definition instead explicitly given values. 

So how MVVM friendly PowerToys are?
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.
Andrej Benedik

Forum Jump:

Users browsing this thread:
1 Guest(s)