Pre loader

Per-window MouseEventGroup using bindings.

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

Hello again.

As you’ve suggested in other posts, to avoid mouse events broadcasting across multiple windows with charts (and in my case, crashing said windows, ’cause they’re in multiple UI threads), I do binding like this:

<sciChart:ModifierGroup mouse:MouseManager.MouseEventGroup="{Binding MouseGroupId}">

Where MouseGroupId is just a GUID converted to a string. The problem is, this binding (or any binding, even for the constant string in the view model) doesn’t work. Binding trace is as follows:

System.Windows.Data Warning: 55 : Created BindingExpression (hash=43894578) for Binding (hash=31482310)
System.Windows.Data Warning: 57 : Path: 'MouseGroupId'
System.Windows.Data Warning: 59 : BindingExpression (hash=43894578): Default mode resolved to OneWay
System.Windows.Data Warning: 60 : BindingExpression (hash=43894578): Default update trigger resolved to PropertyChanged
System.Windows.Data Warning: 61 : BindingExpression (hash=43894578): Attach to Abt.Controls.SciChart.ModifierGroup.MouseEventGroup (hash=44711291)
System.Windows.Data Warning: 66 : BindingExpression (hash=43894578): Resolving source
System.Windows.Data Warning: 69 : BindingExpression (hash=43894578): Found data context element: ModifierGroup (hash=44711291) (OK)
System.Windows.Data Warning: 77 : BindingExpression (hash=43894578): Activate with root item ChartPanelViewModelProxy (hash=11922526)
System.Windows.Data Warning: 107 : BindingExpression (hash=43894578): At level 0 – for ChartPanelViewModelProxy.MouseGroupId found accessor RuntimePropertyInfo(MouseGroupId)
System.Windows.Data Warning: 103 : BindingExpression (hash=43894578): Replace item at level 0 with ChartPanelViewModelProxy (hash=11922526), using accessor RuntimePropertyInfo(MouseGroupId)
System.Windows.Data Warning: 100 : BindingExpression (hash=43894578): GetValue at level 0 from ChartPanelViewModelProxy (hash=11922526) using RuntimePropertyInfo(MouseGroupId): 'Mouse831A0392'
System.Windows.Data Warning: 79 : BindingExpression (hash=43894578): TransferValue – got raw value 'Mouse831A0392'
System.Windows.Data Warning: 88 : BindingExpression (hash=43894578): TransferValue – using final value 'Mouse831A0392'
System.Windows.Data Warning: 95 : BindingExpression (hash=43894578): Got PropertyChanged event from ModifierGroup (hash=44711291) for DataContext
System.Windows.Data Warning: 78 : BindingExpression (hash=43894578): Deactivate
System.Windows.Data Warning: 102 : BindingExpression (hash=43894578): Replace item at level 0 with {NullDataItem}
System.Windows.Data Warning: 77 : BindingExpression (hash=43894578): Activate with root item <null>
System.Windows.Data Warning: 105 : BindingExpression (hash=43894578): Item at level 0 is null – no accessor
System.Windows.Data Warning: 79 : BindingExpression (hash=43894578): TransferValue – got raw value {DependencyProperty.UnsetValue}
System.Windows.Data Warning: 87 : BindingExpression (hash=43894578): TransferValue – using fallback/default value <null>
System.Windows.Data Warning: 88 : BindingExpression (hash=43894578): TransferValue – using final value <null>
System.Windows.Data Warning: 78 : BindingExpression (hash=43894578): Deactivate
System.Windows.Data Warning: 102 : BindingExpression (hash=43894578): Replace item at level 0 with {NullDataItem}
System.Windows.Data Warning: 62 : BindingExpression (hash=43894578): Detach

So, the getter on view model is being called, and binding receives the initial value, but then ModifierGroup loses its data context, and the bound value is lost.

Because I use the chart in the ItemsControl (while looking forward to using the SciChartGroup, when it’ll be released), the charts are created by the ItemsControl and I couldn’t find an event that’ll allow me to set mouse event group programmatically.

So, how should I do this, prefereably with MVVM?

Full itemscontrol xaml is like this:

    &lt;ItemsControl x:Name=&quot;PanelContainer&quot; ItemsSource=&quot;{Binding Panels}&quot;&gt;
        &lt;ItemsControl.ItemsPanel&gt;
            &lt;ItemsPanelTemplate&gt;
                &lt;UniformGrid Columns=&quot;1&quot; /&gt;
            &lt;/ItemsPanelTemplate&gt;
        &lt;/ItemsControl.ItemsPanel&gt;

        &lt;ItemsControl.ItemTemplate&gt;
            &lt;DataTemplate&gt;
                &lt;sciChart:SciStockChart BarTimeFrame=&quot;{Binding BarTimeFrame, UpdateSourceTrigger=PropertyChanged}&quot;
                                        SeriesSource=&quot;{Binding ChartSeries}&quot;
                                        XAxisVisibleRange=&quot;{Binding ElementName=ChartContainer, Path=DataContext.SharedXVisibleRange, Mode=TwoWay}&quot;
                                        sciChart:SciChartGroup.VerticalChartGroup=&quot;{Binding VerticalGroupId}&quot;
                                        sciChart:ThemeManager.Theme=&quot;BlackSteel&quot;&gt;
                    &lt;sciChart:SciChartSurface.ChartModifier&gt;
                        &lt;sciChart:ModifierGroup mouse:MouseManager.MouseEventGroup=&quot;{Binding MouseGroupId, PresentationTraceSources.TraceLevel=High}&quot;&gt;
                            &lt;sciChart:RubberBandXyZoomModifier IsXAxisOnly=&quot;True&quot; ReceiveHandledEvents=&quot;True&quot; /&gt;
                            &lt;sciChart:MouseWheelZoomModifier /&gt;
                            &lt;sciChart:RolloverModifier ReceiveHandledEvents=&quot;True&quot; /&gt;
                            &lt;sciChart:XAxisDragModifier /&gt;
                            &lt;sciChart:ZoomExtentsModifier ExecuteOn=&quot;MouseDoubleClick&quot; /&gt;
                        &lt;/sciChart:ModifierGroup&gt;
                    &lt;/sciChart:SciChartSurface.ChartModifier&gt;
                &lt;/sciChart:SciStockChart&gt;
            &lt;/DataTemplate&gt;
        &lt;/ItemsControl.ItemTemplate&gt;
    &lt;/ItemsControl&gt;

Also, what’s the right way to use SciChartOverview with the ItemsControl, again, preferably with MVVM? (I’ve found SciChartOverview.BackgroundChartSurface in change log, but couldn’t do anything with it.

  • You must to post comments
0
0

Ok. I don;t know why that doesn’t work – it should. The method you’ve proposed seems sound. My only suggestion is to look for any other binding errors as they occasionally prevent the binding engine from continuing to evaluate other bindings (well, i’ve seem some wierd behaviour around this before lets say).

Another idea is – as you’ve pointed out – set the binding in code. What about SciChartSurface.Loaded event? This should be fired when the Item is created. Alternatively you could create a derived class of ItemsControl and override ItemsControl.GetContainerForItemOverride or using this hack workaround to get a notification of items changed.

Try those, let me know how it goes. You’re right MouseManager is not multi-UI thread safe as it forwards events to each child surface in the same group. Maybe we should look at this.

Best regards,
Andrew

  • You must to post comments
0
0

I am considering applying server-side licensing for my javerScript application.

In the document below, there is a phrase “Our server-side licensing component is written in C++.”
(https://support.scichart.com/index.php?/Knowledgebase/Article/View/17256/42/)

However, there is only asp.net sample code on the provided github.
(https://github.com/ABTSoftware/SciChart.JS.Examples/tree/master/Sandbox/demo-dotnet-server-licensing)

I wonder if there is a sample code implemented in C++ for server-side licensing.

Can you provide c++ sample code?
Also, are there any examples to run on Ubuntu?

  • Andrew Burnett-Thompson
    Ok, I got around to investigating this today. Sorry about the delay! Turns out there is a bug (1-line of code fix) in SciChartSurface.cs. When we detach and re-attach a chart modifier (occurs during application of themes) then the ChartModifier.DataContext is set to null. This means your binding stops working as soon as the theme is applied to the chart. I've fixed this and have committed it to both our 1.6 branch and v2.0 branch, so soon will be in both. Thanks for reporting, and for the excellent solution to reproduce! Best regards, Andrew
  • gman
    I've upgraded to v1.7.0.2424 and it works with the bindings now, thanks!
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies