SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.


I am using the MVVM pattern with WPF SciChart
I need to show multiple graphs where each graph may show multiple line series.

I am currently trying to get most of the features in the Scichart Trader demo application working with my code in an MVVM way.

I am currently not able to get the rollover feature to work.

The only difference is that I did not specify a MouseEventGroup (again because I cannot hard code any of my charts or chart items).

  _chartModifiers = new ModifierGroup();
  //_chartModifiers.MouseEventGroup = "KINGFORADAY";

If I provide a mouse event group as indicated in the previous line by uncommenting the code I get the following exception:
“The given key was not present in the dictionary.”

I included the stack trace at the bottom of the question.

Can you please suggest what I need to do so that I can rollover across more that one chart as in your example but using MVVM?

Here are my two chart definitions that for now share a common view model but each with different properties that they bind to.
The attached behavior allows me to load the various chart modifers.

  XAxis="{Binding XAxis, Mode=TwoWay}" 
  YAxes="{Binding ChartYAxes}"
  DataSet="{Binding ChartData}"
  RenderableSeries="{Binding HistoricalRenderableSeries}"
  ChartModifier="{Binding ChartModifiers}"
  local:LoadChartModifiersAttachedBehavior.LoadChartModifiers="{Binding LoadChartModifers, Mode=TwoWay}"/>

  XAxis="{Binding XAxis2, Mode=TwoWay}" 
  YAxes="{Binding ChartYAxes2}"
  DataSet="{Binding ChartData2}"
  RenderableSeries="{Binding HistoricalRenderableSeries2}"
  ChartModifier="{Binding ChartModifiers2}"
  local:LoadChartModifiersAttachedBehavior.LoadChartModifiers="{Binding LoadChartModifers2, Mode=TwoWay}">

Here is the stack trace.

at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Abt.Controls.SciChart.Utility.Mouse.MouseManager.(IReceiveMouseEvents )
at Abt.Controls.SciChart.Utility.Mouse.MouseManager..(Object , MouseEventArgs )
at .(MouseEventArgs )
at .(Object , MouseEventArgs )
at System.Windows.Input.MouseEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at Asset_Health_Client.App.Main() in E:\wencocodesource2010\Source2010\Management\Client\Main\Trunk\Client\Client\obj\x86\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

  • You must to post comments

Hello again and thanks for your query 🙂

I just took a quick look at ModifierGroup and the property MouseEventGroup is only used internally by Scichart.

In Xaml there is an attached property which is typically set like this:

   <ModifierGroup s:MouseManager.MouseEventGroup="MyGroup"/>

The equivalent in code would be this:

_chartModifiers = new ModifierGroup();
MouseManager.SetMouseEventGroup(_chartModifiers, "MyGroup");

Can you try that and let me know if you get a better result?

Finally one of our users recently reported an issue with the MouseEventGroup attached property. He wanted to have just a subset of modifiers in the group link the mouse event. As a work around we helped him create a custom modifier to link Rollovers in code. The class is attached (MasterRolloverModifier)

Usage is as follows:

You can declare the rollover in xaml or code as before. When you want to link Rollover A to B you must do this in code:

// Assuming you have two rollovers declared as follows
var master = new MasterRolloverModifier();
var child0 = new MasterRolloverModifier(); 

// You can link the events between them so A triggers B and vice versa as follows

One caveat – with the above approach if you have N rollover modifiers you need to register N-1 children with each one! We need to come up with a better API to link mouse events between charts. I do hope that somewhere in here you can find a workaround to your problem.

  • sdemooy
    Hi, Thanks adding MouseManager.SetMouseEventGroup(_chartModifiers, "MyGroup"); works.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.