Events of EventManger not raised
#1
Hi,

we're evaluating the framework since a few days. When working in the code behind of the main view there were no problems with raising events which we're consuming from the event manager.
Now we tried to implement a GUI with 2 views in MVVM pattern. In one view we want to create the boxes according to user requirements and in the second view we want to be able to interact with them (e.g. selecting). Thus we've 2 views and 2 view models. We declared one event manager per view and registered it to the right viewport. We're using the same code for creating and registering the visuals and the eventmanager. The only thing which changed is that we're using now Binding to the Content- Property of the ModelVisual3D within the Viewport3D. Before we're directly manipulating it in the code behind.
Before;
...
<Viewport3D Name="MainViewport" MinHeight="1000">
                <ModelVisual3D x:Name="MainViewPortModel">
                </ModelVisual3D>
                <ModelVisual3D>
                    <ModelVisual3D.Content>
                        <Model3DGroup>
                            <AmbientLight Color="#333333"/>
                        </Model3DGroup>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
            </Viewport3D>

...
Code behind:
In code behind we directly manipulated the Children and Content property of the MainViewPort:
 e.g.:  MainViewportModel.Children.Add(wireGridVisual3D);
MainViewPortModel.Content = newBoxes; //newBoxes is a Model3DGroup

Now with MVVM:
<Viewport3D Name="EditorViewport" MinHeight="1000">
                <ModelVisual3D x:Name="EditorViewportModel">
                    <ModelVisual3D.Content>
                        <Model3DGroup>
                            <AmbientLight Color="#333333"/>
                        </Model3DGroup>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
                <ModelVisual3D Content="{Binding ElementCollection.Content, UpdateSourceTrigger=PropertyChanged}">
                    </ModelVisual3D>
 </Viewport3D>

In the ViewModel:
ElementCollection is a ModelVisual3D object and we're manipulating it like this:
ElementCollection .Children.Add(wireGridVisual3D);
ElementCollection .Content = newBoxes;


We can display all the same stuff but the events in the EventManager are not raised anymore when trying to interact with the visuals. What is wrong with our approach? Whats the best way to achieve the correct behavior?

Best,
Andreas
#2
Hm, it is hard to say what is the reason for the problem because I do not see the whole code.

But from the code that you have posted, it looks like you have named only the ModelVisual3D that have one AmbientLight (EditorViewportModel) but the ModelVisual3D that contains your 3D model does not define a name - how do you reference it from the code when using EventManager3D? If this ModelVisual3D is not used as an event source, then how do you register event source objects to EventManager3D?
Andrej Benedik
  


Forum Jump:


Users browsing this thread:
1 Guest(s)