We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Right Click context menu separator

Thread ID:

Created:

Updated:

Platform:

Replies:

101567 Nov 2,2011 07:06 PM UTC Nov 7,2011 02:50 AM UTC WPF 1
loading
Tags: Chart
George G
Asked On November 2, 2011 07:06 PM UTC

How do you add a menu separator to a Syncfusion chart right click context menu?

This is a dynamic menu and can't be done directly in XAML.

We're using Syncfusion.Chart.WPF.DLL version 9.203.0.137 in a .net 4.0 WPF desktop application.

Here is a simplified version of our code to create the chart and right click menu.

Chart g = new SyncFusion.Windows.Chart.Chart();

..setup other chart properties

ChartArea chartArea = new ChartArea();

..setup other chart area properties

chartArea.IsContextMenuEnabled = true;
chartArea.ContextMenuType = ContextMenuTypes.Custom;

//add menu items to right click context menu

MenuItem m = new MenuItem();
m.Header = "Show test dialog";
m.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(ShowTextDialog_OnClick);
chartArea.CustomContextMenuItems.Add(m);

//separator should go here

MenuItem m2 = new MenuItem();
m2.Header = "Show test dialog2";
m2.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(ShowTextDialog2_OnClick);
chartArea.CustomContextMenuItems.Add(m2);

g.Areas.Add(chartArea);




Ganesan [Syncfusion]
Replied On November 7, 2011 02:50 AM UTC

Hi George,


We have analyzed your requirement, and there is no special support for adding a separator to the context menu. But your requirement can be achieved by overriding the datatemplate of contextmenuitem header as in below code snippet.


Code Snippet [Xaml]:







Code Snippet [C#]:

area.IsContextMenuEnabled = true;

area.ContextMenuType = ContextMenuTypes.Custom;

ContextMenu menu = new ContextMenu();

MenuItem seperator = new MenuItem();

seperator.Height = 7;

seperator.Width = 200;

seperator.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch;

seperator.HeaderTemplate = this.Resources["Seperator"] as DataTemplate;

seperator.Header = "Seperator Header";

menu.Items.Add("Rotate Series");

menu.Items.Add("Zomming");

menu.Items.Add(seperator);

menu.Items.Add("Print");

menu.Items.Add("Save");

area.ContextMenu = menu;


Based on your requirement we have created a simple sample, which you can download from the link below.


http://www.syncfusion.com/downloads/Support/DirectTrac/86851/WPFChartCase1011509621.zip


Please let us know if you have any concerns.


Thanks,

Ganesan




CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;