Trading Chart: Programmatic Access To Hamburger Menu Items?

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
User avatar
JeffFerguson
Posts: 9
Joined: Wed Oct 07, 2020 1:25 am

Trading Chart: Programmatic Access To Hamburger Menu Items?

Post by JeffFerguson » Fri Nov 20, 2020 10:01 pm

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?

Arction_LasseP
Posts: 141
Joined: Wed Mar 27, 2019 1:05 pm

Re: Trading Chart: Programmatic Access To Hamburger Menu Items?

Post by Arction_LasseP » Mon Nov 23, 2020 8:59 am

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.

Code: Select all

_chart.SetAppearance(Appearance.Dark);
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:

Code: Select all

        private void TrendLineButton_Click(object sender, RoutedEventArgs e)
        {
            TrendLine line = new TrendLine();
            _chart.DrawingTools.Add(line);
            line.StartDrawing();
        }
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

User avatar
JeffFerguson
Posts: 9
Joined: Wed Oct 07, 2020 1:25 am

Re: Trading Chart: Programmatic Access To Hamburger Menu Items?

Post by JeffFerguson » Tue Nov 24, 2020 12:30 am

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!

Post Reply