Trading Chart: Programmatic Access To Hamburger Menu Items?
Moderator: Queue Moderators
- JeffFerguson
- Posts: 9
- Joined: Wed Oct 07, 2020 1:25 am
Trading Chart: Programmatic Access To Hamburger Menu Items?
I have a TradingChart instance with the hamburger menu enabled. Is there an programmatic way to access the tools and color scheme selections in the menu? For example, if I wanted to build a toolbar that had a button that, when clicked, started the Trend Line tool, how do I launch that Trend Line tool from code such that the toolbar button does just what the Trend Line menu item does?
-
- Posts: 141
- Joined: Wed Mar 27, 2019 1:05 pm
Re: Trading Chart: Programmatic Access To Hamburger Menu Items?
Hello Jeff,
It might be tricky to access the hamburger menu directly. However, all the functionalities found in the menu can easily be called in code as well. Changing color-theme can be done by calling SetAppearance() method.
Drawing Tool drawing can be instantiated by calling StartDrawing() for a newly created tool. Calling this starts drawing the tool next time you click the chart. For instance, the following starts drawing a new TrendLine when a button is clicked:
This is actually exactly the same code the hamburger menu is using. It also works with all the Drawing Tools, not just TrendLine.
Hope this is helpful.
Best regards,
Lasse
It might be tricky to access the hamburger menu directly. However, all the functionalities found in the menu can easily be called in code as well. Changing color-theme can be done by calling SetAppearance() method.
Code: Select all
_chart.SetAppearance(Appearance.Dark);
Code: Select all
private void TrendLineButton_Click(object sender, RoutedEventArgs e)
{
TrendLine line = new TrendLine();
_chart.DrawingTools.Add(line);
line.StartDrawing();
}
Hope this is helpful.
Best regards,
Lasse
- JeffFerguson
- Posts: 9
- Joined: Wed Oct 07, 2020 1:25 am
Re: Trading Chart: Programmatic Access To Hamburger Menu Items?
Thank you! This is indeed what I was looking for. I did not want to access the menu items programmatically; instead, as you suggested, I wanted to access the functionality of the items programmatically. This answer is what I needed. Thank you again!