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

XAML Menu to match Control center

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

    XAML Menu to match Control center

    I'm working on a custom addon window that has a menu on it. Is there a way to make the Menu's foreground and background match the user's selected skin? Or a way to use the same Menu used on the Control Center?

    For example my window looks like this when the "Light" skin is used (looks fine): http://puu.sh/BpTdn/37f0ca30a6.png

    But looks like this when the default "Slate Gray" is used: http://puu.sh/BpTh1/695fbc2199.png

    Below is the XAML, I've tried both MenuItem and NTMenuItem for the items but it's the parent menu that seems to be the issue. (It's interesting that both ComboBox and TextBox adjust to the new skin)

    Code:
    <DockPanel>
            [B]<Menu DockPanel.Dock="Top" >[/B]
                <MenuItem Header="_Edit">
                    <MenuItem Header="_Alerts"/>
                    <MenuItem Header="_Primary Zones" Click="PrimaryZones_ZoneParameters_Click" />
                    <MenuItem Header="_Order Handling" />
                </MenuItem>
                <t:NTMenuItem Header="_Open"/>
                <ComboBox Width="150">
                    <ComboBoxItem>ComboBox Item #1</ComboBoxItem>
                    <ComboBoxItem IsSelected="True">ComboBox Item #2</ComboBoxItem>
                    <ComboBoxItem>ComboBox Item #3</ComboBoxItem>
                </ComboBox>
                <MenuItem Header="_Save" Name="SaveTemplateButton"/>
                <TextBox Name="TemplateNameTextBox" Width="150" ></TextBox>
            </Menu>
            <Frame x:Name="frame" Content="Frame" Height="401" VerticalAlignment="Top" NavigationUIVisibility="Hidden"  />
    
    
        </DockPanel>

    #2
    Hi HandsFreeTrader,

    Yeah you can pick brushes from the skin by using resource names.

    Attached is an example.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks, was a pain to get the menu styles but I think I have the menus working the way I want. Only thing I can't figure out is how to get the menu to appear in the NTWindow header. Any suggestions?

      Ideally it would look like the CC menu here: http://puu.sh/BqkC7/2d4f68e899.png
      Last edited by HandsFreeTrader; 09-05-2018, 05:17 PM.

      Comment


        #4
        Hi HandsFreeTrader,

        Add to the MainMenu object.
        Code:
        Loaded += (o, e) => { MainMenu.Add(new Button() { Content = " Hello" }); };

        Also, your menu objects can use the SystemMenuStyle style I think.
        Code:
        Style = System.Windows.Application.Current.TryFindResource("SystemMenuStyle") as Style
        Last edited by NinjaTrader_ChelseaB; 09-06-2018, 08:36 AM.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks the new menu works great.

          Figured this is unsupported but wanted to try asking here since I haven't had any luck finding info on this elsewhere.

          Notice when I mouse over the menu it highlights everything: https://www.screencast.com/t/EXmV4wfpdX

          Is there a way to prevent this? I've tried setting FocusVisualStyle = null and a few other custom styles but so far no luck.

          Comment


            #6
            Hi HandsFreeTrader,

            Try setting the UseOverflowMenu to true in the NTWindow class constructor.

            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Wow, thank you. Didn't expect it to be that basic.

              Comment


                #8
                Is it possible to use the Brush selector combobox directly in a custom window?

                Only way I can think of right now is searching for the AutomationId: "cbxBrushes" in a window like DataSeries and then creating my own combobox off of that. This works but is very tedious and I'm wondering if there is a better solution.

                Comment


                  #9
                  Hello HandsFreeTrader,

                  Thank you for the post.

                  The specific brush dropdown you see in the property grid could be recreated in an addon by using a property grid and supplying an object to it with a Brush property. This would use the type converter to display the correct editor.

                  Otherwise, to directly use the control in your own code without the property grid specifically, you would still need to reference the Propertygrid's dll for this control.

                  Here is a xaml example of the brush selector:
                  Code:
                  xmlns:PGrid="clr-namespace:System.Windows.Controls.WpfPropertyGrid.Controls;assembly=System.Windows.Controls.WpfPropertyGrid" 
                  
                  <PGrid:BrushPicker x:Name="bPicker">
                  	<PGrid:BrushPicker.SelectedBrush>
                  		<Brush>Red</Brush>
                  	</PGrid:BrushPicker.SelectedBrush>
                  </PGrid:BrushPicker>

                  Or from code:
                  Code:
                  System.Windows.Controls.WpfPropertyGrid.Controls.BrushPicker brushPicker = new System.Windows.Controls.WpfPropertyGrid.Controls.BrushPicker();
                  brushPicker.SelectedBrush = Brushes.Red;
                  The dll for this is located in the C:\Program Files (x86)\NinjaTrader 8\bin64 folder as System.Windows.Controls.WpfPropertyGrid.dll

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

                  Comment


                    #10
                    thanks that works great.

                    Wanted to note to anyone who might try this later on that VS will throw an error in the XAML saying cannot find resource BrushPicker item. But it will still compile and work when loaded into NT as long as the reference is added as mentioned above.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by DJ888, 04-16-2024, 06:09 PM
                    4 responses
                    12 views
                    0 likes
                    Last Post DJ888
                    by DJ888
                     
                    Started by terofs, Today, 04:18 PM
                    0 responses
                    11 views
                    0 likes
                    Last Post terofs
                    by terofs
                     
                    Started by nandhumca, Today, 03:41 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post nandhumca  
                    Started by The_Sec, Today, 03:37 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post The_Sec
                    by The_Sec
                     
                    Started by GwFutures1988, Today, 02:48 PM
                    1 response
                    9 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Working...
                    X