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

0
0

I’ve implemented the following ContextMenu:

  <s:SciChartSurface.ContextMenu>
            <ContextMenu>
                <MenuItem x:Name ="header1" Header="Einfügen" Command="{Binding InsertItem}" IsEnabled="{Binding SelectedElementsCount,Converter={StaticResource BoolToOppositeBoolConverter}}" />
                <MenuItem Header="Entfernen" Command="{Binding RemoveItem}" />
                <MenuItem x:Name ="header2" Header="Ändern" Command="{Binding ChangeItem}" IsEnabled="{Binding SelectedElementsCount,Converter={StaticResource BoolToOppositeBoolConverter}}" />
                <MenuItem x:Name ="header3" Header="Verschieben" Command="{Binding ChangeItem}" IsEnabled="{Binding SelectedElementsCount}" />
            </ContextMenu>
        </s:SciChartSurface.ContextMenu>

This still worked, but I have changed the AnnotationsCanvas from the Annotations to AboveChart and the Context Menu doesn’t show if I press the right mouse button:

<s:SciChartSurface.Annotations>

            <!-- Draws Bands behind each axis -->
            <s:BoxAnnotation YAxisId="Ch0" Style="{StaticResource BoxAnnotationStyle0}" X1="0" X2="1" Y1="{Binding VisibleRange.Min, ElementName=Ch0}" Y2="{Binding VisibleRange.Max, ElementName=Ch0}" AnnotationCanvas="AboveChart"  PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />
            <s:BoxAnnotation YAxisId="Ch1" Style="{StaticResource BoxAnnotationStyle1}" X1="0" X2="1" Y1="{Binding VisibleRange.Min, ElementName=Ch1}" Y2="{Binding VisibleRange.Max, ElementName=Ch1}" AnnotationCanvas="AboveChart"   PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />
            <s:BoxAnnotation YAxisId="Ch2" Style="{StaticResource BoxAnnotationStyle0}" X1="0" X2="1" Y1="{Binding VisibleRange.Min, ElementName=Ch2}" Y2="{Binding VisibleRange.Max, ElementName=Ch2}" AnnotationCanvas="AboveChart"  PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />
            <s:BoxAnnotation YAxisId="Ch3" Style="{StaticResource BoxAnnotationStyle1}" X1="0" X2="1" Y1="{Binding VisibleRange.Min, ElementName=Ch3}" Y2="{Binding VisibleRange.Max, ElementName=Ch3}" AnnotationCanvas="AboveChart" PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />

            <s:BoxAnnotation YAxisId="Ch1" Name="boxAnnotationCh1" Style="{StaticResource ScichartBoxAnnotationColor_Geometry}" BorderThickness="1" CornerRadius="0"
                             X1="{Binding Coord_CH1.X1,Mode=TwoWay}"  X2="{Binding Coord_CH1.X2,Mode=TwoWay}"  Y1="{Binding Coord_CH1.Y1,Mode=TwoWay}"  Y2="{Binding Coord_CH1.Y2,Mode=TwoWay}"
                             AnnotationCanvas="AboveChart"   PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />
            <s:BoxAnnotation YAxisId="Ch2" Name="boxAnnotationCh2"  Style="{StaticResource ScichartBoxAnnotationColor_Geometry}" BorderThickness="1" CornerRadius="3"
                             X1="{Binding Coord_CH2.X1}"  X2="{Binding Coord_CH2.X2}"  Y1="{Binding Coord_CH2.Y1}"  Y2="{Binding Coord_CH2.Y2}"
                             PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown"
                             AnnotationCanvas="AboveChart" />
            <s:BoxAnnotation YAxisId="Ch3" Name="boxAnnotationCh3"  Style="{StaticResource ScichartBoxAnnotationColor_Geometry}" BorderThickness="1" CornerRadius="3"
                             X1="{Binding Coord_CH3.X1}"  X2="{Binding Coord_CH3.X2}"  Y1="{Binding Coord_CH3.Y1}"  Y2="{Binding Coord_CH3.Y2}"
                             PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />

            <!-- Draws a Header line into each chart -->
            <s:TextAnnotation Text="{lex:Loc NominalGeometryInput:Resources:AxisDirection}" YAxisId="Ch1"  X1="0" X2="1" Y1="{Binding VisibleRange.Min, ElementName=Ch1}" Y2="{Binding VisibleRange.Max, ElementName=Ch1}" Style="{StaticResource ScichartChartHeaderStyle}"  AnnotationCanvas="AboveChart"  PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />
            <s:TextAnnotation Text="{lex:Loc NominalGeometryInput:Resources:AxisSuperelevation}" YAxisId="Ch2"  X1="0" X2="1" Y1="{Binding VisibleRange.Min, ElementName=Ch2}" Y2="{Binding VisibleRange.Max, ElementName=Ch2}" Style="{StaticResource ScichartChartHeaderStyle}"  AnnotationCanvas="AboveChart"  PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />
            <s:TextAnnotation Text="{lex:Loc NominalGeometryInput:Resources:AxisElevation}" YAxisId="Ch3"  X1="0" X2="1" Y1="{Binding VisibleRange.Min, ElementName=Ch3}" Y2="{Binding VisibleRange.Max, ElementName=Ch3}" Style="{StaticResource ScichartChartHeaderStyle}"  AnnotationCanvas="AboveChart"  PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />
        </s:SciChartSurface.Annotations>
  • You must to post comments
1
0

Hi Daniel,

This is probably due to the WPF Event Routing where another element higher in the Visual Tree is handling the event, hence the ContextMenu never receives it.

We have a number of FAQs on this topic here and hopefully one will give you a good workaround to show a context menu with SciChart:

Best regards,
Andrew

  • You must to post comments
1
0

Hi Daniel,

I’ve created a Visual Studio solution to attempt to reproduce this issue, and I can’t.

I am using SciChart v3.3.3.6243, visual studio 2013 Update 4 (although I don’t think VS version is relevant).

Here is my code:

XAML

<Window x:Class="WpfApplication9.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:s="http://schemas.abtsoftware.co.uk/scichart"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <s:SciChartSurface>

            <s:SciChartSurface.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Hello!"  />
                </ContextMenu>
            </s:SciChartSurface.ContextMenu>

            <s:SciChartSurface.YAxis>
                <s:NumericAxis x:Name="Ch0"/>
            </s:SciChartSurface.YAxis>
            <s:SciChartSurface.XAxis>
                <s:NumericAxis/>
            </s:SciChartSurface.XAxis>

            <s:SciChartSurface.Annotations>

                <!-- Draws Bands behind each axis -->
                <s:BoxAnnotation Background="#33FF0000" X1="0" X2="1" Y1="{Binding VisibleRange.Min, ElementName=Ch0}" Y2="{Binding VisibleRange.Max, ElementName=Ch0}" AnnotationCanvas="AboveChart"  PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />

            </s:SciChartSurface.Annotations>
        </s:SciChartSurface>
    </Grid>
</Window>

Code Behind

using System.Windows;
using System.Windows.Input;

namespace WpfApplication9
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void BoxAnnotation_PreviewMouseMove(object sender, MouseEventArgs e)
        {

        }

        private void BoxAnnotation_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {            
        }
    }
}

And here is the result:

enter image description here

As you can see the context menu shows. Can you download our attached solution and modify it until the error occurs (Context Menu does not show)? You will need to enable NuGet package restore to get it to compile by right clicking the solution -> Click on ‘Enable NuGet Package Restore’

Best regards,
Andrew

  • You must to post comments
0
0

I implemented Point “Display a menu chart”. The OnSurfaceContextMenuOpening event of the ContextMenuModifier got called if I press mouse and alt but the context Menu isn’t showing:

<UserControl x:Class="NominalGeometryInput.ChartView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:s="http://schemas.abtsoftware.co.uk/scichart"
         xmlns:lex="http://wpflocalizeextension.codeplex.com"
         xmlns:Nominal="clr-namespace:NominalGeometryInput"
         xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
         xmlns:inf="clr-namespace:Modules.Infrastructure;assembly=Modules.Infrastructure"
         xmlns:modules="clr-namespace:Modules.Infrastructure"
         xmlns:prism="http://www.codeplex.com/prism"
         xmlns:System="clr-namespace:System;assembly=mscorlib"
         lex:LocalizeDictionary.DesignCulture="de"
         lex:ResxLocalizationProvider.DefaultAssembly="NominalGeometryInput"
         lex:ResxLocalizationProvider.DefaultDictionary="Resources"
         d:DesignHeight="600"
         d:DesignWidth="800"
         Loaded="UserControl_Loaded"
         mc:Ignorable="d"
         IsTabStop="False">

<UserControl.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="../GlobalDictionary.xaml" />
        </ResourceDictionary.MergedDictionaries>
        <inf:BoolToOppositeBoolConverter x:Key="BoolToOppositeBoolConverter" />
        <Style x:Key="MajorTickLineStyle" TargetType="Line">
            <Setter Property="Stroke" Value="Transparent" />
            <Setter Property="StrokeThickness" Value="0" />
            <Setter Property="X2" Value="0" />
            <Setter Property="Y2" Value="0" />
        </Style>

        <Style x:Key="YAxisBaseStyle" TargetType="s:AxisBase">
            <Setter Property="VisibleRange" Value="-2, 2" />
            <Setter Property="VisibleRangeLimit" Value="-2, 2" />
            <Setter Property="AutoRange" Value="Never" />
            <Setter Property="DrawMinorGridLines" Value="False" />
            <Setter Property="DrawMinorTicks" Value="False" />
            <Setter Property="DrawMajorGridLines" Value="False" />
            <Setter Property="DrawMajorBands" Value="False" />
            <Setter Property="TickLabelStyle" Value="{x:Null}" />
            <Setter Property="DrawLabels" Value="False" />
            <Setter Property="MaxAutoTicks" Value="0" />
            <Setter Property="MajorTickLineStyle" Value="{StaticResource MajorTickLineStyle}" />
        </Style>

        <Style x:Key="SelectionStyle" TargetType="{x:Type Shape}">
            <Setter Property="Fill" Value="#33AAAAAA" />
            <Setter Property="Stroke" Value="LightGray" />
            <Setter Property="StrokeThickness" Value="1" />
            <Setter Property="StrokeDashArray" Value="2, 2" />
        </Style>

        <System:Boolean x:Key="True">True</System:Boolean>
        <System:Boolean x:Key="False">False</System:Boolean>

        <ItemsPanelTemplate x:Key="YAxesPanelVertical">
            <Grid>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="2*" />
                    <ColumnDefinition Width="1*" />
                    <ColumnDefinition Width="30*" />
                    <ColumnDefinition Width="1*" />
                    <ColumnDefinition Width="30*" />
                    <ColumnDefinition Width="1*" />
                    <ColumnDefinition Width="30*" />
                </Grid.ColumnDefinitions>
            </Grid>
        </ItemsPanelTemplate>
        <ItemsPanelTemplate x:Key="YAxesPanelHorizontal">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="4*" />
                    <RowDefinition Height="1*" />
                    <RowDefinition Height="26*" />
                    <RowDefinition Height="1*" />
                    <RowDefinition Height="26*" />
                    <RowDefinition Height="1*" />
                    <RowDefinition Height="26*" />
                </Grid.RowDefinitions>
            </Grid>
        </ItemsPanelTemplate>
    </ResourceDictionary>
</UserControl.Resources>
<UserControl.InputBindings>
    <KeyBinding Key="End" Command="{Binding MoveToLastElement}"></KeyBinding>
    <KeyBinding Key="Home" Command="{Binding MoveToFirstElement}" />
    <KeyBinding Modifiers="Shift" Key="Tab" Command="{Binding MoveToPreviouseElement}" />
    <KeyBinding Key="Tab" Command="{Binding MoveToNextElement}" />
    <KeyBinding Key="Up" Command="{Binding Move10m}" CommandParameter="{StaticResource True}" />
    <KeyBinding Key="Down" Command="{Binding Move10m}" CommandParameter="{StaticResource False}" />
    <KeyBinding Key="Enter" Command="{Binding ChangeItem}" />
    <KeyBinding Key="Delete" Command="{Binding RemoveItem}" />
</UserControl.InputBindings>

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="16" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="16" />
    </Grid.ColumnDefinitions>
    <s:SciChartSurface x:Name="sciChart" Grid.Row="0" s:ThemeManager.Theme="Chrome"
                       s:RenderSurfaceBase.RenderSurfaceType="Abt.Controls.SciChart.Rendering.HighQualityRasterizer.HighQualityRenderSurface"
                       PreviewMouseLeftButtonDown="sciChart_PreviewMouseLeftButtonDown"
                       Padding="0"
                       MouseRightButtonUp="sciChart_MouseRightButtonUp"
                       Style="{StaticResource ScichartBackgroundColor}"
                       GridLinesPanelStyle="{StaticResource ScichartGridLinesPanelStyle}">
        <s:SciChartSurface.Resources>
            <Style TargetType="s:SciChartSurface">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding ChartOrientation,UpdateSourceTrigger=PropertyChanged,Mode=OneWay}" Value="{x:Static inf:ChartOrientations.Vertical}">
                        <Setter Property="TopAxesPanelTemplate" Value="{DynamicResource YAxesPanelVertical}" />
                        <Setter Property="BottomAxesPanelTemplate" Value="{DynamicResource YAxesPanelVertical}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ChartOrientation,UpdateSourceTrigger=PropertyChanged,Mode=OneWay}" Value="{x:Static inf:ChartOrientations.Horizontal}">
                        <Setter Property="LeftAxesPanelTemplate" Value="{DynamicResource YAxesPanelHorizontal}" />
                        <Setter Property="RightAxesPanelTemplate" Value="{DynamicResource YAxesPanelHorizontal}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </s:SciChartSurface.Resources>
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="MouseDoubleClick">
                <i:InvokeCommandAction Command="{Binding Path=ChangeItem, Mode=OneWay}" />
            </i:EventTrigger>
            <prism:InteractionRequestTrigger SourceObject="{Binding  ItemAddRequestSynchro, Mode=OneWay}">
                <prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True">
                    <prism:PopupWindowAction.WindowContent>
                        <Nominal:SynchroAddView />
                    </prism:PopupWindowAction.WindowContent>
                </prism:PopupWindowAction>
            </prism:InteractionRequestTrigger>
            <prism:InteractionRequestTrigger SourceObject="{Binding  ItemSelectionRequestDirection, Mode=OneWay}">
                <prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True">
                    <prism:PopupWindowAction.WindowContent>
                        <Nominal:GeometrySelectionView />
                    </prism:PopupWindowAction.WindowContent>
                </prism:PopupWindowAction>
            </prism:InteractionRequestTrigger>
            <prism:InteractionRequestTrigger SourceObject="{Binding  ItemAddRequestDirection, Mode=OneWay}">
                <prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True">
                    <prism:PopupWindowAction.WindowContent>
                        <Nominal:GeometryAddView />
                    </prism:PopupWindowAction.WindowContent>
                </prism:PopupWindowAction>
            </prism:InteractionRequestTrigger>
            <prism:InteractionRequestTrigger SourceObject="{Binding  ItemSelectionRequestLongitudinal, Mode=OneWay}">
                <prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True">
                    <prism:PopupWindowAction.WindowContent>
                        <Nominal:GeometrySelectionViewLongi />
                    </prism:PopupWindowAction.WindowContent>
                </prism:PopupWindowAction>
            </prism:InteractionRequestTrigger>
            <prism:InteractionRequestTrigger SourceObject="{Binding  ItemShiftSelectionRequest, Mode=OneWay}">
                <prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True">
                    <prism:PopupWindowAction.WindowContent>
                        <Nominal:GeomtryShiftView />
                    </prism:PopupWindowAction.WindowContent>
                </prism:PopupWindowAction>
            </prism:InteractionRequestTrigger>
        </i:Interaction.Triggers>
        <s:SciChartSurface.RenderableSeries>
            <s:XyScatterRenderableSeries YAxisId="Ch0" DataSeries="{Binding DataCH0_Manual}">
                <s:SquarePointMarker Width="9" Height="9" Fill="LightGreen" Stroke="Green" StrokeThickness="1" />
            </s:XyScatterRenderableSeries>
            <s:XyScatterRenderableSeries YAxisId="Ch0" DataSeries="{Binding DataCH0_Automatic}">
                <s:SquarePointMarker Width="9" Height="9" Fill="LightGreen" Stroke="Red" StrokeThickness="1" />
            </s:XyScatterRenderableSeries>
            <s:FastLineRenderableSeries Style="{StaticResource ScichartSeriesColor_Geometry}" YAxisId="Ch1" DataSeries="{Binding DataCH1}" />
            <s:FastLineRenderableSeries Style="{StaticResource ScichartSeriesColor_Geometry}" YAxisId="Ch2" DataSeries="{Binding DataCH2}" />
            <s:FastLineRenderableSeries Style="{StaticResource ScichartSeriesColor_Geometry}" YAxisId="Ch3" DataSeries="{Binding DataCH3}" />
        </s:SciChartSurface.RenderableSeries>
        <s:SciChartSurface.ContextMenu>
            <ContextMenu  IsOpen="{Binding IsOpen, Mode=OneWay,UpdateSourceTrigger=PropertyChanged}">
                <MenuItem x:Name ="header1" Header="Einfügen" Command="{Binding InsertItem}" IsEnabled="{Binding SelectedElementsCount,Converter={StaticResource BoolToOppositeBoolConverter}}" />
                <MenuItem Header="Entfernen" Command="{Binding RemoveItem}" />
                <MenuItem x:Name ="header2" Header="Ändern" Command="{Binding ChangeItem}" IsEnabled="{Binding SelectedElementsCount,Converter={StaticResource BoolToOppositeBoolConverter}}" />
                <MenuItem x:Name ="header3" Header="Verschieben" Command="{Binding ChangeItem}" IsEnabled="{Binding SelectedElementsCount}" />
            </ContextMenu>
        </s:SciChartSurface.ContextMenu>

        <s:SciChartSurface.YAxes>
            <s:NumericAxis x:Name="Ch0"  Id="Ch0"  Style="{StaticResource YAxisBaseStyle}" Grid.Row="0" />
            <s:NumericAxis x:Name="Ch1" Id="Ch1" Style="{StaticResource YAxisBaseStyle}" Grid.Row="2" />
            <s:NumericAxis x:Name="Ch2"  Id="Ch2" Style="{StaticResource YAxisBaseStyle}" Grid.Row="4" />
            <s:NumericAxis x:Name="Ch3"  Id="Ch3" Style="{StaticResource YAxisBaseStyle}" Grid.Row="6" />
        </s:SciChartSurface.YAxes>

        <s:SciChartSurface.XAxis>
            <s:NumericAxis x:Name="xAxis"  VisibleRange="{Binding ChartXRange,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
        </s:SciChartSurface.XAxis>

        <s:SciChartSurface.ChartModifier>
            <s:ModifierGroup>
                <Nominal:GeometryCursorModifier x:Name="geometryCursorModifier"
                                                NominalGeometry="{Binding NominalGeometry,UpdateSourceTrigger=PropertyChanged,Mode=OneWay}"
                                                SelectedDirSupElements="{Binding SelectedElementsDirSup}"
                                                SelectedLongiElements="{Binding SelectedElementsLongi}"
                                                SelectedChartLine="{Binding SelectedChartLineMouseDown}"
                                                CurrentPosition="{Binding CurrentPosition,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                                CurrentElement="{Binding CurrentElement,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                                ChartXRange="{Binding ChartXRange,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                                ChartOrientation="{Binding ChartOrientation}" />
                <Nominal:GeometryMultipleSelector x:Name="geometryMultipleSelector"
                                                  IsEnabled="True"
                                                  SelectionPolygonStyle="{StaticResource SelectionStyle}"
                                                  ChartOrientation="{Binding ChartOrientation}"
                                                  Geometry="{Binding NominalGeometry,UpdateSourceTrigger=PropertyChanged}"
                                                  SelectedDirSupElements="{Binding SelectedElementsDirSup}"
                                                  SelectedLongiElements="{Binding SelectedElementsLongi}"
                                                  DeleteDirection="{Binding DeleteElementDirection,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                                  DeleteSuperelevation="{Binding DeleteElementSuperelevation,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                                  DeleteLongitudinal="{Binding DeleteElementLongitudinal, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                                  CurrentPosition="{Binding CurrentPosition,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
                <Nominal:GeometryToolTipModifier x:Name="geometryToolTipModifier"
                                                NominalGeometry="{Binding NominalGeometry,UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"
                                                SelectedChartLine="{Binding SelectedChartLineMouseMove}"
                                                ChartOrientation="{Binding ChartOrientation}" />

                <inf:ContextMenuModifier x:Name="ContextMenuModifier"  IsOpen="{Binding IsOpen, Mode=TwoWay}" />
            </s:ModifierGroup>
        </s:SciChartSurface.ChartModifier>

        <s:SciChartSurface.Annotations>

            <!-- Draws Bands behind each axis -->
            <s:BoxAnnotation YAxisId="Ch0" Style="{StaticResource BoxAnnotationStyle0}" X1="0" X2="1" Y1="{Binding VisibleRange.Min, ElementName=Ch0}" Y2="{Binding VisibleRange.Max, ElementName=Ch0}" AnnotationCanvas="AboveChart"  PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />
            <s:BoxAnnotation YAxisId="Ch1" Style="{StaticResource BoxAnnotationStyle1}" X1="0" X2="1" Y1="{Binding VisibleRange.Min, ElementName=Ch1}" Y2="{Binding VisibleRange.Max, ElementName=Ch1}" AnnotationCanvas="AboveChart"   PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />
            <s:BoxAnnotation YAxisId="Ch2" Style="{StaticResource BoxAnnotationStyle0}" X1="0" X2="1" Y1="{Binding VisibleRange.Min, ElementName=Ch2}" Y2="{Binding VisibleRange.Max, ElementName=Ch2}" AnnotationCanvas="AboveChart"  PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />
            <s:BoxAnnotation YAxisId="Ch3" Style="{StaticResource BoxAnnotationStyle1}" X1="0" X2="1" Y1="{Binding VisibleRange.Min, ElementName=Ch3}" Y2="{Binding VisibleRange.Max, ElementName=Ch3}" AnnotationCanvas="AboveChart" PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />

            <s:BoxAnnotation YAxisId="Ch1" Name="boxAnnotationCh1" Style="{StaticResource ScichartBoxAnnotationColor_Geometry}" BorderThickness="1" CornerRadius="0"
                             X1="{Binding Coord_CH1.X1,Mode=TwoWay}"  X2="{Binding Coord_CH1.X2,Mode=TwoWay}"  Y1="{Binding Coord_CH1.Y1,Mode=TwoWay}"  Y2="{Binding Coord_CH1.Y2,Mode=TwoWay}"
                             AnnotationCanvas="AboveChart"   PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />
            <s:BoxAnnotation YAxisId="Ch2" Name="boxAnnotationCh2"  Style="{StaticResource ScichartBoxAnnotationColor_Geometry}" BorderThickness="1" CornerRadius="3"
                             X1="{Binding Coord_CH2.X1}"  X2="{Binding Coord_CH2.X2}"  Y1="{Binding Coord_CH2.Y1}"  Y2="{Binding Coord_CH2.Y2}"
                             PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown"
                             AnnotationCanvas="AboveChart" />
            <s:BoxAnnotation YAxisId="Ch3" Name="boxAnnotationCh3"  Style="{StaticResource ScichartBoxAnnotationColor_Geometry}" BorderThickness="1" CornerRadius="3"
                             X1="{Binding Coord_CH3.X1}"  X2="{Binding Coord_CH3.X2}"  Y1="{Binding Coord_CH3.Y1}"  Y2="{Binding Coord_CH3.Y2}"
                             PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />

            <!-- Draws a Header line into each chart -->
            <s:TextAnnotation Text="{lex:Loc NominalGeometryInput:Resources:AxisDirection}" YAxisId="Ch1"  X1="0" X2="1" Y1="{Binding VisibleRange.Min, ElementName=Ch1}" Y2="{Binding VisibleRange.Max, ElementName=Ch1}" Style="{StaticResource ScichartChartHeaderStyle}"  AnnotationCanvas="AboveChart"  PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />
            <s:TextAnnotation Text="{lex:Loc NominalGeometryInput:Resources:AxisSuperelevation}" YAxisId="Ch2"  X1="0" X2="1" Y1="{Binding VisibleRange.Min, ElementName=Ch2}" Y2="{Binding VisibleRange.Max, ElementName=Ch2}" Style="{StaticResource ScichartChartHeaderStyle}"  AnnotationCanvas="AboveChart"  PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />
            <s:TextAnnotation Text="{lex:Loc NominalGeometryInput:Resources:AxisElevation}" YAxisId="Ch3"  X1="0" X2="1" Y1="{Binding VisibleRange.Min, ElementName=Ch3}" Y2="{Binding VisibleRange.Max, ElementName=Ch3}" Style="{StaticResource ScichartChartHeaderStyle}"  AnnotationCanvas="AboveChart"  PreviewMouseMove="BoxAnnotation_PreviewMouseMove" PreviewMouseDown="BoxAnnotation_PreviewMouseDown" />
        </s:SciChartSurface.Annotations>
    </s:SciChartSurface>
    <Grid Grid.Column="1">
        <Grid.RowDefinitions>
            <RowDefinition Height="10*" />
            <RowDefinition Height="20*" />
            <RowDefinition Height="133*" />
            <RowDefinition Height="6*" />
            <RowDefinition Height="133*" />
            <RowDefinition Height="6*" />
            <RowDefinition Height="133*" />
            <RowDefinition Height="20*" />
        </Grid.RowDefinitions>
        <Slider Focusable="False" Grid.Row="2" Value="{Binding ScichartCH1SliderValue, UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" Minimum="100" Maximum="2000" Orientation="Vertical" Width="22">
            <Slider.LayoutTransform>
                <ScaleTransform ScaleX="0.72" />
            </Slider.LayoutTransform>
        </Slider>
        <Slider Focusable="False" Grid.Row="4" Value="{Binding ScichartCH2SliderValue, UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" Minimum="10" Maximum="500" Orientation="Vertical" Width="22" IsDirectionReversed="True">
            <Slider.LayoutTransform>
                <ScaleTransform ScaleX="0.72" />
            </Slider.LayoutTransform>
        </Slider>
        <Slider Focusable="False" Grid.Row="6" Value="{Binding ScichartCH3SliderValue, UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" Minimum="100" Maximum="20000" Orientation="Vertical" Width="22">
            <Slider.LayoutTransform>
                <ScaleTransform ScaleX="0.72" />
            </Slider.LayoutTransform>
        </Slider>
    </Grid>
    <Grid Grid.Row="1">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="10*" />
            <ColumnDefinition Width="20*" />
            <ColumnDefinition Width="133*" />
            <ColumnDefinition Width="3*" />
            <ColumnDefinition Width="133*" />
            <ColumnDefinition Width="3*" />
            <ColumnDefinition Width="133*" />
        </Grid.ColumnDefinitions>
        <Slider Focusable="False" Grid.Column="2" Value="{Binding ScichartCH1SliderValue, UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" Minimum="100" Maximum="10000" Orientation="Horizontal" Height="22">
            <Slider.LayoutTransform>
                <ScaleTransform ScaleY="0.72" />
            </Slider.LayoutTransform>
        </Slider>
        <Slider Focusable="False" Grid.Column="4" Value="{Binding ScichartCH2SliderValue, UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" Minimum="10" Maximum="500" Orientation="Horizontal" Height="22" IsDirectionReversed="True">
            <Slider.LayoutTransform>
                <ScaleTransform ScaleY="0.72" />
            </Slider.LayoutTransform>
        </Slider>
        <Slider Focusable="False" Grid.Column="6" Value="{Binding ScichartCH3SliderValue, UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" Minimum="100" Maximum="20000" Orientation="Horizontal" Height="22">
            <Slider.LayoutTransform>
                <ScaleTransform ScaleY="0.72" />
            </Slider.LayoutTransform>
        </Slider>
    </Grid>
    <ScrollBar
        Focusable="False"
        SmallChange="10"
        LargeChange="100"
        Value="{Binding ScichartScrollbarValue ,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
        ViewportSize="{Binding ScichartViewportSize ,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
        Minimum="{Binding ScichartRangeMin ,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
        Maximum="{Binding ScichartRangeMax ,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}">
        <ScrollBar.LayoutTransform>
            <RotateTransform Angle="{Binding ScichartScrollbarDirection, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" CenterX="0.5" CenterY="0.5" />
        </ScrollBar.LayoutTransform>
        <ScrollBar.Resources>
            <Style TargetType="ScrollBar">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding ChartOrientation,UpdateSourceTrigger=PropertyChanged,Mode=OneWay}" Value="{x:Static inf:ChartOrientations.Vertical}">
                        <Setter Property="Grid.Column" Value="1" />
                        <Setter Property="Orientation" Value="Vertical" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ChartOrientation,UpdateSourceTrigger=PropertyChanged,Mode=OneWay}" Value="{x:Static inf:ChartOrientations.Horizontal}">
                        <Setter Property="Grid.Row" Value="1" />
                        <Setter Property="Orientation" Value="Horizontal" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </ScrollBar.Resources>
    </ScrollBar>
</Grid>

  • You must to post comments
0
0

Yes it doesn’t work, contextmenu will not show, but binding and OnSurfaceContextMenuOpening event still work??

  • You must to post comments
0
0

I’ve created a sample project. And the causer are the textannotations, if set to belowChart still works, set to above chart->no Context Menu

Attachments
  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.