Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Buttons-StackPanels-DockPanels

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

    #46
    Originally posted by richbois View Post
    Thank you for the great work

    Is there a way to change the font and the background color on these buttons????

    Thank you in advance

    Try this:

    Code:
    Style s = new Style();
                                s.TargetType = typeof(Button);
                                s.Setters.Add(new Setter(Button.FontSizeProperty, 12.0));
                                s.Setters.Add(new Setter(Button.BackgroundProperty, Brushes.DimGray));
                                s.Setters.Add(new Setter(Button.ForegroundProperty, Brushes.GhostWhite));
                                s.Setters.Add(new Setter(Button.FontFamilyProperty, new FontFamily("Courier New")));
                                s.Setters.Add(new Setter(Button.FontWeightProperty, FontWeights.Bold));
    
                                
                                btnProperties = new Button();
                                btnProperties.Name = "btnProperties";
                                btnProperties.Style = s;
    
                                etc.

    Comment


      #47
      Thanks cls71. That worked for me. I was getting an ambigous button error so I had to update mine a bit but that may have been because I had different settings already.

      Here is what I used below. I just had to replace Button with System.Windows.Controls.Button

      Style s = new Style();
      s.TargetType = typeof(System.Windows.Controls.Button);
      s.Setters.Add(new Setter(System.Windows.Controls.Button.FontSizeProp erty, 12.0));
      s.Setters.Add(new Setter(System.Windows.Controls.Button.BackgroundPr operty, Brushes.DimGray));
      s.Setters.Add(new Setter(System.Windows.Controls.Button.ForegroundPr operty, Brushes.GhostWhite));
      s.Setters.Add(new Setter(System.Windows.Controls.Button.FontFamilyPr operty, new FontFamily("Courier New")));
      s.Setters.Add(new Setter(System.Windows.Controls.Button.FontWeightPr operty, FontWeights.Bold));


      By the way this also is allowing the width of the buttons to be more narrow now which answers the question in post #43

      Comment


        #48
        Now that I have updated the style per cls71's code the button turns blue when the mouse is over it. What property sets what happens when the mouse is over the button? Can we set this in the button style properties? Thanks.

        Comment


          #49
          I am using jhowinvest code and the button changes color when Mouse Over

          Comment


            #50
            That's because the styles defined in the skin, which are inherited by your button.

            But I do not dominate this issue, I am not able to help, sorry.

            Inside the file Documents \ NinjaTrader 8 \ templates \ Skins \ <your skin> \ BluePrint.xaml, search the strings:

            <! - Button border ->
            <! - Background states button ->
            <! - Button ->

            there you will find the colors used in those events.


            I have not been able to eliminate a style from C # code. Only from XAML, but it is complicated to use it within NinjaScript.

            Comment


              #51
              I have another question

              I use to use btnX_selected=false;

              what would replace that code

              Thanks

              Comment


                #52
                Originally posted by cls71 View Post
                That's because the styles defined in the skin, which are inherited by your button.

                But I do not dominate this issue, I am not able to help, sorry.

                Inside the file Documents \ NinjaTrader 8 \ templates \ Skins \ <your skin> \ BluePrint.xaml, search the strings:

                <! - Button border ->
                <! - Background states button ->
                <! - Button ->

                there you will find the colors used in those events.


                I have not been able to eliminate a style from C # code. Only from XAML, but it is complicated to use it within NinjaScript.
                I just noticed that in NT7 code it was doing the same before you click in other words the mouse over does change the color before click

                Comment


                  #53
                  Originally posted by -=Edge=- View Post
                  btn.Width = (int);
                  btn.Height = (int);


                  Thanks Edge. I have been able to use that property to make the buttons wider but not make them more narrow. There seems to be a default set somehow that will not allow the buttons to be more narrow. Maybe in the dockpanel? I have worked with the horizontalalignment and horizontalcontentalignment and see the difference there but making the buttons really narrow/skinny is evading me. Any ideas? Thanks again for all of your work on this topic.
                  Hi.
                  I had the same problem and fixed it by setting the minwidth property to 0 :
                  btn.MinWidth = 0;

                  Comment


                    #54
                    I have been playing with these buttons since yesterday and still have some issue

                    The On button is not working properly

                    It is supposed to change color when ENABLE and change the enable from true to false etc

                    This is very similar code that i had in NT7

                    The strategy starts correctly but when i press the ON button it doesn't change color properly and freezes

                    I include the strategy

                    Can someone please show me where my error is???

                    Thank you in advance
                    Attached Files

                    Comment


                      #55
                      Originally posted by richbois View Post
                      Can someone please show me where my error is???
                      It looks like you were using the IsEnabled property incorrectly. IsEnabled determines whether the button itself is enabled, not whether it is in a state of "On" or "Off," which in terms of the code itself is completely arbitrary. I was able to get the button to change colors as expected by creating a new bool which will track whether the button is "On" or "Off" in terms of the value you are trying to track, rather than in terms of the button actually being enabled or disabled. I then added logic to test that bool in the btnONIsActive_Click callback method, and then change the button's color and content accordingly.

                      I've attached an updated version of the script for your reference.
                      Attached Files
                      Dave I.NinjaTrader Product Management

                      Comment


                        #56
                        Thank You very much Dave

                        Comment


                          #57
                          Nice to finally see more interest and collaboration on this subject!


                          -=Edge=-
                          NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

                          Comment


                            #58
                            These help documents may not be new in the ninjascript section but I just noticed them and thought I would post them here. Thank you to the NT team for putting these together. I think that will help all of us as well as anyone new who looks at this thread. Another thank you again to everyone who has contributed and especially Edge for starting the thread.



                            Comment


                              #59
                              Thank you -- those are both brand new pages we put up in response to users requesting and discussing these items. We created the second page (using images with Buttons) based on this thread, since it was a very useful discussion. This way no one else will need to struggle through the process.
                              Dave I.NinjaTrader Product Management

                              Comment


                                #60
                                Originally posted by jhowinvest View Post
                                These help documents may not be new in the ninjascript section but I just noticed them and thought I would post them here. Thank you to the NT team for putting these together. I think that will help all of us as well as anyone new who looks at this thread. Another thank you again to everyone who has contributed and especially Edge for starting the thread.



                                http://ninjatrader.com/support/helpG...th_buttons.htm
                                We actually just put them together last week; glad you noticed them and found them helpful. Thanks for sharing!
                                MatthewNinjaTrader Product Management

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by andrewtrades, Today, 04:57 PM
                                1 response
                                8 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Started by chbruno, Today, 04:10 PM
                                0 responses
                                6 views
                                0 likes
                                Last Post chbruno
                                by chbruno
                                 
                                Started by josh18955, 03-25-2023, 11:16 AM
                                6 responses
                                436 views
                                0 likes
                                Last Post Delerium  
                                Started by FAQtrader, Today, 03:35 PM
                                0 responses
                                7 views
                                0 likes
                                Last Post FAQtrader  
                                Started by rocketman7, Today, 09:41 AM
                                5 responses
                                19 views
                                0 likes
                                Last Post NinjaTrader_Jesse  
                                Working...
                                X