Is there a way to identify which pane in a chart the mouse is over?

Hypothetical - say you have an SfChart in WPF, and you have added multiple panes to that chart by adding ChartRowDefinitions. 

Is there a way to determine which pane of the chart the mouse is currently over? In this case, I want to resize that pane by holding down CTRL (left) and rolling the mouse wheel forward or back. How to adjust the overall chart height is easy, but I'm not sure how to tell which pane I'm over in order just to change the height of that pane. 


1 Reply

AJ Arul Jenith Berkmans Syncfusion Team June 27, 2025 01:06 PM UTC

Hi Thomas Brand,

 

You can achieve your scenario by handling the mouse event on the chart. This will help you determine which pane (chart row) the mouse is currently over, and you can then resize that particular pane. Below is a sample code snippet to illustrate this approach:

 

private void SfChart_MouseDown(object sender, MouseButtonEventArgs e)

{

var chart = sender as SfChart;

Point mousePosition = e.GetPosition(chart);

 

double totalHeight = chart.ActualHeight;

int rowCount = chart.RowDefinitions.Count;

 

// Calculate the height of each row (assuming equal height rows)

double rowHeight = totalHeight / rowCount;

 

// Determine which row the mouse is in

int hoveredRow = (int)(mousePosition.Y / rowHeight);

 

var selectedpane = chart.RowDefinitions[hoveredRow];

selectedpane.Height = 50;

 

Console.WriteLine($"Mouse is in row {hoveredRow}");

}

 

We have also attached the sample for your reference.

 

Regards,

Arul Jenith B.


Attachment: WPFStackedColumn_ebc3e8b0.zip

Loader.
Up arrow icon