Hi,
How can I capture an event (mouse event or something like that) in my ViewModel after zooming or panning the chart.
Thanks,
Egbert
- EJansen asked 11 years ago
- You must login to post comments
Hi again,
Please, take a look on this example:
<SciChart:NumericAxis AxisTitle="Time (ms)" TextFormatting="0.00" VisibleRange="{Binding XVisibleRange, Mode=TwoWay}"> <i:Interaction.Triggers> <i:EventTrigger EventName="VisibleRangeChanged"> <local:ExecuteCommandAction Command="{Binding OnVisibleRangeChanged}" /> </i:EventTrigger> </i:Interaction.Triggers> </SciChart:NumericAxis>
ExecuteCommandAction class:
public class ExecuteCommandAction : TriggerAction<Control> { public static readonly DependencyProperty CommandProperty = DependencyProperty.Register("Command", typeof(ICommand), typeof(ExecuteCommandAction), new PropertyMetadata(null)); public ICommand Command { get { return (ICommand)GetValue(CommandProperty); } set { SetValue(CommandProperty, value); } } protected override void Invoke(object parameter) { if(Command != null && Command.CanExecute(null)) { Command.Execute(null); } } }
Could you try out this approach and give us a feedback if this is what you want?
Yuriy
- Yuriy Zadereckiy answered 11 years ago
-
Hi, Thanks, it works great now. Your first answer already gave me the solution. We are using the following xaml code:
<SciChart:SciChartSurface Grid.Column="0" Grid.Row="0" x:Name="sciChartSurface" DataSet="{Binding ChartData, Mode=TwoWay}" RenderableSeries="{Binding RenderableSeries}" SciChart:ThemeManager.Theme="{Binding SciChartTheme}" XAxis="{Binding XAxis}" YAxes="{Binding YAxes}" Annotations="{Binding Annotations}" ChartModifier="{Binding ChartModifier}" > </SciChart:SciChartSurface>
In the ViewModel we are using: this.XAxis.VisibleRangeChanged += new EventHandler(VisibleRangeChangedEvent); and the same for the Yaxes
- You must login to post comments
Hi there,
When you zoom or pan a chart, VisibleRange changed and VisibleRangeChanged event fired on axes. So you could bind this event to command in your ViewModel using EventTriggers and InvokeCommandAction.
Please, feel free to ask if you have any questions!
Best regards,
Yuriy
- Yuriy Zadereckiy answered 11 years ago
- You must login to post comments
Please login first to submit.