-
Notifications
You must be signed in to change notification settings - Fork 981
Description
In the current WPF implementation, AxisChanged (from stable 4.0.48) and AxesChanged (from 4.1.5-beta) always provide null as sender. Is there a reason why the WpfPlot instance cannot specify this as the sender?
A typical and convenient way to match the axes of e.g. 10 plots would be like this:
private void WpfPlot_AxesChanged(object sender, EventArgs e)
{
if (sender is WpfPlot plot)
{
foreach (WpfPlot p in linkedPlots)
{
if (!p.Equals(plot))
{
// disable and enable event to prevent loops is omitted for brevity
p.Plot.SetAxisLimits(plot.Plot.GetAxisLimits());
p.Render();
}
}
}
}and have all anonymous WpfPlot user controls route the AxesChanged event to this single handler. This is not possible though currently, as the sender is null and so we cannot know the WpfPlot whose axes changed. One would need to make 10 different handlers (WpfPlot1_AxesChanged, WpfPlot2_AxesChanged, ...) like it is done in the examples here https://github.com/ScottPlot/ScottPlot/blob/4.0-stable/src/ScottPlot.Demo.WPF/WpfDemos/LinkedPlots.xaml.cs#L36-L46