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 devatechnologies, 04-14-2024, 02:58 PM
          3 responses
          19 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by tkaboris, Today, 08:01 AM
          0 responses
          2 views
          0 likes
          Last Post tkaboris  
          Started by BarzTrading, Today, 07:25 AM
          1 response
          11 views
          1 like
          Last Post NinjaTrader_Clayton  
          Started by EB Worx, 04-04-2023, 02:34 AM
          7 responses
          161 views
          0 likes
          Last Post VFI26
          by VFI26
           
          Started by Mizzouman1, Today, 07:35 AM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Working...
          X