ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Attempting to create contextmenu in .NET
Posted by Philip on Oct-06-2020 23:02
I attempted to create a ContextMenu for your ChartDirector:WPFChartViewer component. ContextMenu corresponds to a mouse "right click" action over a component.

Using the RealTimeZoomScrollWindow example, I added:

<ChartDirector:WPFChartViewer x:Name="WPFChartViewer1" ... >
    <ContextMenu>
        <MenuItem Header="header1" Command="header1"></MenuItem>
        <MenuItem Header="header2" Command="header2"></MenuItem>
    </ContextMenu>
</ChartDirector:WPFChartViewer>

Getting error messages:

Error XLS0502 The type 'WPFChartViewer' does not support direct content. CSharpWPFCharts RealTimeZoomScrollWindow.xaml 76

Error XDG0049 Cannot add content to an object of type "WPFChartViewer". CSharpWPFCharts RealTimeZoomScrollWindow.xaml 76


Am I correct to believe that ChartDirector:WPFChartViewer does not support ContextMenu?

Philip

  Re: Attempting to create contextmenu in .NET
Posted by Peter Kwan on Oct-07-2020 11:02
Hi Philip,

I think ContextMenu should be added is an attachment property, not as content. So it should be like:

<ChartDirector:WPFChartViewer x:Name="WPFChartViewer1" ... >
<ChartDirector:WPFChartViewer.ContextMenu>
<ContextMenu>
<MenuItem Header="header1"></MenuItem>
<MenuItem Header="header2"></MenuItem>
</ContextMenu>
</ChartDirector:WPFChartViewer.ContextMenu>
</ChartDirector:WPFChartViewer>

Hope this can help.

Regards
Peter Kwan

  Re: Attempting to create contextmenu in .NET
Posted by Peter Kwan on Oct-07-2020 11:12
Hi Philip,

For real time charts, there is some additional multi-threading examples in:

https://www.advsofteng.com/tutorials/extra.html

The above examples use one thread to obtain the data, and the other thread to plot the data.

It is also possible to use one (or multiple) threads to plot the data. The method is usually if there are many real time charts on the display or for charts, such as if there is a screen full of meters and charts.

Regards
Peter Kwan

  Re: Attempting to create contextmenu in .NET
Posted by Philip on Oct-07-2020 20:52
Your suggestion worked.

        <ChartDirector:WPFChartViewer x:Name="WPFChartViewer1" ... >
            <ChartDirector:WPFChartViewer.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="header1"></MenuItem>
                    <MenuItem Header="header2"></MenuItem>
                </ContextMenu>
            </ChartDirector:WPFChartViewer.ContextMenu>
        </ChartDirector:WPFChartViewer>

Thanks