Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

How to get custom Button font to change with skin change.

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

    How to get custom Button font to change with skin change.

    Hi,

    I am using this to create a custom button in NT8:

    Code:
    MyButton = new System.Windows.Controls.Button();
    MyButton.Style = System.Windows.Application.Current.TryFindResource("Button") as Style;
    But "Style" doesn't seem to include the font color, so when I change skins, the button background color changes to match, but the font does not, and thus becomes unreadable going from white to black background.

    Is there a way I can get the new Font color as well as the background?

    Thanks

    #2
    Hello,

    Thank you for the reply.

    I wanted to check, if you do not specify a style at all, do you get the current skins coloring for the button with font? While using an Addon this should be the default for buttons used, if you are placing the button in other places and seeing otherwise could you provide an example?

    The style resource name "Button" may not be the same resource key that is the default for all buttons.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      Thanks for the response. I deleted that line, and it does now work (this is an indicator adding a button to the charwindow toolbar). Seems odd that it had picked up the background if the resource key is different, but as long as it works i'm happy...

      Comment


        #4
        For the record,

        Sample to get the style of Chart Trader buttons:

        Code:
        LinearGradientBrush ChartTraderButtonStyle = System.Windows.Application.Current.TryFindResource("ChartTrader.ButtonBackground") as LinearGradientBrush;

        Or if you want more control, this duplicates the button style above using the "Dark" skin:

        Code:
        ChartTraderButtonStyle.StartPoint = new Point(.5,-.05);
        ChartTraderButtonStyle.EndPoint = new Point(.5,.66);
        GradientStop gs1 = new GradientStop();
        gs1.Color = Color.FromArgb(255, 179, 179, 179);
        gs1.Offset = 0;
        ChartTraderButtonStyle.GradientStops.Add(gs1);
        GradientStop gs2 = new GradientStop();
        gs2.Color = Colors.Black;
        gs2.Offset = 1;
        ChartTraderButtonStyle.GradientStops.Add(gs2);

        Comment


          #5
          var skin = Core.Globals.GeneralOptions.Skin;

          if (skin == "Slate Gray" || skin == "Slate Dark" || skin == "Dark")
          {

          }

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by bortz, 11-06-2023, 08:04 AM
          47 responses
          1,607 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Today, 05:56 PM
          0 responses
          9 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          19 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by Jon17, Today, 04:33 PM
          0 responses
          6 views
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          15 views
          0 likes
          Last Post Javierw.ok  
          Working...
          X