I’m using the VC-Scene Graph Panel WPF project. In addition I would like to focus a specific component by clicking the corresponding node on the WPF panel.
Currently I have two classes:
- public partial class SceneGraphPanelView : UserControl which is the partial class for the WPF UserControl
- public class SceneGraphPanelViewModel : DockableScreen, IPlugin which accesses the VC simulation
What I’ve tried yet is to add an EventHandler to the WPF class which will be triggert on the MouseDown Event when clicking on a node in the WPF Treeview. I try to listen to that event than in the SceneGraphPanelViewModel class in order to focus the component afterwards.
public partial class SceneGraphPanelView : UserControl
{
public event EventHandler<string> FokusCompEvent;
void MouseLeftDown(object sender, MouseEventArgs e)
{
...
FokusCompEvent?.Invoke(this, nodeName);
}
}
public class SceneGraphPanelViewModel : DockableScreen, IPlugin
{
public SceneGraphPanelViewModel()
{
SceneGraphPanelView sG = new SceneGraphPanelView();
sG.FokusCompEvent += SG_FokusCompEvent;
}
private void SG_FokusCompEvent(object sender, string clickedNodeName)
{
MS.AppendMessage(clickedNodeName, MessageLevel.Warning);
}
}
I would expect, that the name of the node will be printed, but it seems that there is a problem. When I listen to the event in any other class in my namespace it works, but not in the SceneGraphPanelViewModel class.
Could there be an issue because of IPlugin or DockableScreen?
Any suggestion on how to solve that or an other approach?
Thanks.