• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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>
            <Menu DockPanel.Dock="Top" >
                <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.

            https://ninjatrader.com/support/foru...795#post532795
            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 mrtorture, Today, 08:11 AM
                    1 response
                    4 views
                    0 likes
                    Last Post NinjaTrader_Heath  
                    Started by Aporshnev, Today, 07:55 AM
                    1 response
                    4 views
                    0 likes
                    Last Post NinjaTrader_PatrickG  
                    Started by tonynt, Today, 08:12 AM
                    0 responses
                    2 views
                    0 likes
                    Last Post tonynt
                    by tonynt
                     
                    Started by tff2011, Yesterday, 03:55 PM
                    1 response
                    4 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by lunardiplomacy, Today, 07:52 AM
                    0 responses
                    6 views
                    0 likes
                    Last Post lunardiplomacy  
                    Working...
                    X