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

Setting the Style of menu items / buttons

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

    Setting the Style of menu items / buttons

    Hello,

    I have an NTMenuItem i set up and then attach to chartcontrol parent.
    All good

    I set the style of this as follows :

    Margin = new System.Windows.Thickness(0),
    Padding = new System.Windows.Thickness(1),
    VerticalAlignment = System.Windows.VerticalAlignment.Center,
    Style = System.Windows.Application.Current.TryFindResource ("MainMenuItem") as System.Windows.Style

    I then add a ToggleButton new System.Windows.Controls.Primitives.ToggleButton();

    And wanting to set this to be the same style as menuitem -
    when skin color is changed in ninja from dark to light i want them to be in synch.

    At moment i am setting the Foreground of the togglebutton

    but tried to set the Style and it seemed to mess up the format and layout.

    Is the problem that i only set the style and not try to set other attributes .. as i still had other parts ie FontFamily FontSize adn Background set.

    wondering how to align the styles and in order to manage different background and skins selected by user

    thanks

    #2
    Hello soulfx,

    Thanks for opening the thread.

    Here's what I have put together when adding my own ToggleButton to an indicator that modifies WPF controls:

    The default style appears to be a generic WPF style. I do not know of an instance where this is used in NinjaTrader 8 and the vanilla style tells me it isn't included internally.

    As there is no style for this, you will have to create your own. You could use properties used from other elements to rebuild a style that can inherit the colors set in a skin.

    As a rough example:
    Code:
    myToggleButtonBackground = myButton.GetValue(System.Windows.Controls.Control.BackgroundProperty) as SolidColorBrush;
    myToggleButtonBackgound can then be set when creating the ToggleButton or when creating a Style.

    Please let me know if I may be of further assistance.
    Last edited by NinjaTrader_Jim; 08-22-2017, 11:43 AM.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by frankthearm, Today, 09:08 AM
    8 responses
    32 views
    0 likes
    Last Post frankthearm  
    Started by NRITV, Today, 01:15 PM
    2 responses
    9 views
    0 likes
    Last Post NRITV
    by NRITV
     
    Started by maybeimnotrader, Yesterday, 05:46 PM
    5 responses
    26 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by quantismo, Yesterday, 05:13 PM
    2 responses
    20 views
    0 likes
    Last Post quantismo  
    Started by adeelshahzad, Today, 03:54 AM
    5 responses
    33 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Working...
    X