Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Add draw objects icon to a button

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Add draw objects icon to a button

    I have attached an image of a toolbars in the left side of the chart.

    I used this code:

    btnRuler = new System.Windows.Controls.Button();
    btnRuler.ToolTip = "Ruler";
    btnRuler.Background = Brushes.Transparent;
    btnRuler.Width = 205;
    btnRuler.Height = 30;
    btnRuler.Content = NinjaTrader.Gui.Tools.Icons.DrawRuler; //"Ruler";
    btnRuler.Click += btnRuler_Click;
    System.Windows.Controls.Grid.SetRow(btnRuler, 1);
    VerticalStackPanel.Children.Add(btnRuler);

    Now as you can see in the image the first button which is the ruler button it only draws a little box image. Now my problem is how can I add the draw objects icon successfully? I want those buttons in the image to have an draw objects icon only not a text. I will appreciate someone that could help. Thanks.
    Attached Files

    #2
    Hello,

    Thank you for the post.

    I wanted to check, are you able to import the attached sample and see the correct icon is displayed in the Toolbar? I noted you are using a StackPanel, this could potentially be the cause. If the Toolbar icon works where your current implementation does not, could you provide an export of your script as you have it now?

    I look forward to being of further assistance.
    Attached Files

    Comment


      #3
      I would love to send you the cs file just let me know where can I email it.

      Comment


        #4
        Hello,

        Thank you for the reply.

        After further review, a sample may not be needed. Can you try just changing the FontFamily the button is using? It is likely the base Button style does not have a specific Font set where the Toolbar button does.

        Code:
        btnRuler.FontFamily = Application.Current.TryFindResource("IconsFamily") as FontFamily
        I see this allows me to use the NT icons which are a Font, the string used from Tools.Icons then seem to work in a standard button for me.

        I look forward to being of further assistance.

        Comment


          #5
          It works :-)

          Comment


            #6
            RemoveAllDrawingObjects Icon/Button doesn't delete the drawn objects even though I have put this code:

            private void btnmnuRemoveAllDrawingObjects_Click(object sender, EventArgs e)
            {
            SendKeys.SendWait("^{Delete}");
            }

            but if it's in the main menu on the top of the chart it will work, something wrong when it's in the stack panel in the left grid. Can you help me out on this please.

            Comment


              #7
              Hello luxurious_04,

              As long as you are hitting that line of code to simulate a press of the Ctrl + Delete keys, and you have the hot key configured to Remove All Drawing Objects, you should be able to use the button press to trigger the Remove All Draw Objects prompt.

              I have attached an example of ours that will trigger this from buttons on a Stack Panel. The Remove Draw Objects hotkey will need to be assigned to Ctrl + Delete.

              If there is anything else we can do to assist, please let us know.
              Attached Files

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              574 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              332 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              553 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              551 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X