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

Font vs Style in menu item

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

    Font vs Style in menu item

    Hello, i have a question regarding adding menu items in ninja eg.

    I have most menu items set as follows ...

    topMenuItem1 = new Gui.Tools.NTMenuItem()
    {
    Header = "Menu Item 1",
    Style = System.Windows.Application.Current.TryFindResource ("InstrumentMenuItem") as Style
    };
    topMenuItem1.Click += TopMenuItem1_Click;

    etc

    In the menu i also have added a checkbox item ...

    checkboxOption = new System.Windows.Controls.CheckBox();

    i then setup the attributes for this

    Height
    Content
    IsChecked etc

    All works fine - question is how can i get the Font or fontstyle to be the same as the above style for topMenuItem1 ?
    I realise this is a ninjatrader.gui component - but is there a way to derive the font or fontstyle from this Style to then apply to the checkbox
    OR
    is there a ninjatrade.gui checkbox i can use and set the style and content and all the other attributes ie the callbacks for checked and unchecked?

    At the moment i can see the font is different (but not majorly) but would like to keep it in similar 'style'

    thanks

    #2
    Hello soulfx,

    Thank you for your reply.

    You should be able to get the FontFamily and FontSize etc. from the Menu Item. So you could do something like this to set the same for the checkbox:

    System.Windows.Controls.CheckBox() { FontFamily = topMenuItem1.FontFamily };

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      great thanks for reply. I was hoping and it makes sense it would be available. I will test it out later on

      Comment


        #4
        Hello tried the above. First just setting to the FontFamily - no discernible change at all
        then add FontSize and FontStyle and no discernible change.
        So does not look like this works. Any other suggestions on this?
        thanks

        ..... update

        Could you perhaps check with your colleagues if i need to use a stackpanel and a textblock to achieve this

        and setting the style of the textblock or font etc

        with the checkbox i have defined the content to be = "some text" which is placed next to the checkbox depending on flowdirection set.

        But seems this content is not being set to the fontfamily.

        I tried setting Style attribute of the checkbox but it threw and exception ie did not like or recognise and messed up the whole menus. So that is not an option.
        Last edited by soulfx; 07-29-2020, 03:58 PM.

        Comment


          #5
          Hello wondered if you had a chance to look into this
          thanks

          Comment


            #6
            Hello soulfx,

            I would suggest if possible to avoid using standard WPF controls as menu items here and just use another menu item and make it checkable.

            Code:
            Style mainMenuItemStyle            = System.Windows.Application.Current.TryFindResource("MainMenuItem") as Style;
            
            NTMenuItem myItem = new NTMenuItem()
            {
                            Header                = "Sub-MenuItem 1",
                            Style                = mainMenuItemStyle,
            [B]IsCheckable = true[/B]
            };
            That will give you a similar checkable look to other menus in the platform. The font and other styles would match the main menu item style in this situation or look like a standard menu item.

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

            Comment


              #7
              Thanks - i added this and tried this - adding in the callback functions which seem to be the same as the checkbox - ischecked & isunchecked
              The text is now the same format - and it shows like a pin (vertical or horizontal) if i use instrumentmenuitem style - but it is away at the far right of the menu item - is this expected position of the check marker ? If i use Mainmenuitem as style a tick is used on the left hand side of menu are to the left of the text.. This looks better but i was expecting to see a checkbox as you see
              If you look at the data series window - either tick replay or break at EOD - is this a different style or NTMenuItem?

              If i cant reproduce a check box as with break at EOD - the MainMenuItem style should be fine as i can also use this area for other menu items. So the key is it needs to be defined as MainMenuItem in order to get the tick showing on the left margin of the menu?

              thanks for help

              Comment


                #8
                Hello soulfx,

                The MainMenuItem style was the only one I could see which looked normal or left as I had expected it. The styles are all for specific purposes so if you use the instrument picker style on a different type of menu item it may not look correct.

                The data series window is using a property grid so that would be a different type of checkbox/style being used. That is just part of the property grid and not a control that can be used directly.

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

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by ESHunter, Today, 08:06 PM
                1 response
                5 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by ETFVoyageur, 05-07-2024, 07:05 PM
                18 responses
                144 views
                0 likes
                Last Post bltdavid  
                Started by thumper57, Yesterday, 04:30 PM
                8 responses
                26 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by morrnel, Today, 06:07 PM
                2 responses
                22 views
                0 likes
                Last Post morrnel
                by morrnel
                 
                Started by sastrades, 05-10-2024, 09:59 AM
                3 responses
                58 views
                0 likes
                Last Post rc5781
                by rc5781
                 
                Working...
                X