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:
<ItemsControl x:Name="PanelContainer" ItemsSource="{Binding Panels}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="1" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<sciChart:SciStockChart BarTimeFrame="{Binding BarTimeFrame, UpdateSourceTrigger=PropertyChanged}"
SeriesSource="{Binding ChartSeries}"
XAxisVisibleRange="{Binding ElementName=ChartContainer, Path=DataContext.SharedXVisibleRange, Mode=TwoWay}"
sciChart:SciChartGroup.VerticalChartGroup="{Binding VerticalGroupId}"
sciChart:ThemeManager.Theme="BlackSteel">
<sciChart:SciChartSurface.ChartModifier>
<sciChart:ModifierGroup mouse:MouseManager.MouseEventGroup="{Binding MouseGroupId, PresentationTraceSources.TraceLevel=High}">
<sciChart:RubberBandXyZoomModifier IsXAxisOnly="True" ReceiveHandledEvents="True" />
<sciChart:MouseWheelZoomModifier />
<sciChart:RolloverModifier ReceiveHandledEvents="True" />
<sciChart:XAxisDragModifier />
<sciChart:ZoomExtentsModifier ExecuteOn="MouseDoubleClick" />
</sciChart:ModifierGroup>
</sciChart:SciChartSurface.ChartModifier>
</sciChart:SciStockChart>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
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.
- gman asked 11 years ago
- You must login to post comments
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
- Andrew Burnett-Thompson answered 11 years ago
- You must login to post comments
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?
- gman answered 11 years ago
-
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
-
I've upgraded to v1.7.0.2424 and it works with the bindings now, thanks!
- You must login to post comments
Please login first to submit.