This is a migrated thread and some comments may be shown as answers.

RadDiagramShape MouseOver to trigger RadDiagramContainerShape MouseOver

2 Answers 171 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Tulio
Top achievements
Rank 1
Tulio asked on 25 Jan 2019, 04:03 AM

Hi!

I am using RadDiagram and in my diagram I have a couple of RadDiagramContainerShape with a handful  of RadDiagramShape's inside of it.

I am styling the RadDiagramContainerShape so that it changes color when the mouse is over and that works fine.

However when the mouse is over any of the RadDiagramShape inside of it, it detects as MouseOver=false. I can see that in the visual tree that shapes are not children of Containers, so it seems that is what is causing this behavior.

 

So, to summarize, I am trying to change the background of the Container, when the mouse is over the Container AND over any shape INSIDE of the container.

Is there any way to accomplish what I am trying to do?

 

Thanks!

2 Answers, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 29 Jan 2019, 12:17 PM
Hello Tulio,

I guess you have added MouseOver VisualState in the ControlTemplate of the ContainerShapes. If so, you can subscribe to MouseEnter and MouseLeave events of all shapes, then invoke the MouseOver / Normal states of the Containers that are behind the shape:

EventManager.RegisterClassHandler(typeof(RadDiagramShape), FrameworkElement.MouseEnterEvent, new MouseEventHandler(Shape_MouseEnter));
           hitTestService = this.diagram.ServiceLocator.GetService<IHitTestService>();
       }
 
       private void Shape_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
       {
           RadDiagramShape enteredShape = e.OriginalSource as RadDiagramShape;
           foreach (IShape shape in
               hitTestService.GetShapesNearPoint(enteredShape.Bounds.Center(), 0).OfType<IContainerShape>())
           {
               var container = shape as RadDiagramContainerShape;
               VisualStateManager.GoToState(container, "MouseOver", false);
           }
       }

For more information on HitTestService please find follow documentation article.

Diagram HitTestService

I hope this approach helps you move forward.

Regards,
Petar Mladenov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Tulio
Top achievements
Rank 1
answered on 01 Feb 2019, 06:53 PM
It worked. Thanks!
Tags
Diagram
Asked by
Tulio
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Tulio
Top achievements
Rank 1
Share this question
or