beto-rodriguez / LiveCharts2

Simple, flexible, interactive & powerful charts, maps and gauges for .Net, LiveCharts2 can now practically run everywhere Maui, Uno Platform, Blazor-wasm, WPF, WinForms, Xamarin, Avalonia, WinUI, UWP.
https://livecharts.dev
MIT License
4.35k stars 569 forks source link

Handling pointer events on chart in WPF #528

Closed nadim-241 closed 1 year ago

nadim-241 commented 2 years ago

Describe the bug Subscribing to the DataPointerDown event with the chart in a TabControl container leads to being unable to switch between tab control tabs programmatically after the event occurs. I believe this is because the mouse event goes unhandled somehow (there appears to be no way to handle it like you would a typical MouseEventArgs with args.Handled = true).

To Reproduce Steps to reproduce the behavior: Create a cartesian chart inside a TabControl TabItem, bind the TabControl SelectedIndex to an Integer property which implements INotifyPropertyChanged. Subscribe to the DataPointerDown event with a method in the code behind which alters the SelectedIndex bound property in some way through the ViewModel (make sure to stay within the bounds of the tab index).

Expected behavior Nothing appears to change, however with the debugger we can see that the property is being set to the desired value, and then reset again for no apparent reason (no user written code appears to call the setter the second time, and the call stack is quite opaque).

Desktop (please complete the following information):

Additional context Current solution is to instead subscribe to the TabItem DoubleClick event and handle the mouse event args accordingly.

nadim-241 commented 2 years ago

Aware this is very specific, not sure yet if it can be generalised for subscribing to the chart pointer down event. It would be useful in my specific case since I would like to open a tab depending on what series the user clicks.

beto-rodriguez commented 1 year ago

I think this could also be fixed with the alternative mentioned here.

I will close this for now, please feel free to let me know if the alternative provided is not enough.