Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Properties Panel with 2 or more columns

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

    Properties Panel with 2 or more columns

    Hi Ninjas
    Is possible to do something like this (picture atached) in the properties panel?
    Questions:
    Is possible to change the forecolor (like a picture)?
    Is possible to add a second column like a picture?

    Thanks
    Attached Files

    #2
    Hello,

    Thank you for the post.

    I would not know of a way to color the properties if that was part of this question, as far as adding a second checkbox or column, you would likely need to use an expandable object for this. An expandable object allows you to group properties into an object which can then be expanded or collapsed. You can find an example of this concept at the following link:


    I look forward to being of further assistance.

    Comment


      #3
      I know this is an older post, but I am looking for an example of having checkboxes or input in 2-column as the OP showed in the original posted screenshot. I followed the suggested link, but this did not show a multiple column example. Are there any examples that may have been discussed since this 2017 posting? Thank you.

      Comment


        #4
        Hi, thanks for posting.

        There's no default way to get two columns. You would need to make your own custom class and load Xaml within the custom window to do this. Heres a blank template example that we have:

        Custom Window:

        Code:
        //set up the property in its own .cs file in the Addons folder:
        namespace NinjaTrader.NinjaScript.AddOns
        {
            public class TestWPFWindowSelector : System.Windows.Controls.WpfPropertyGrid.PropertyEditor
            {
                public TestWPFWindowSelector()
                {
                    InlineTemplate = CreateTemplate();
                }
        
                System.Windows.DataTemplate CreateTemplate()
                {
                    const string xamlTemplate = @"
        <DataTemplate >
              <Grid>
                <Grid.ColumnDefinitions>
                  <ColumnDefinition Width=""30""/>
                  <ColumnDefinition Width=""*""/>
                </Grid.ColumnDefinitions>
        
            <Button Grid.Column=""0"" Content=""..."" Padding=""0"" Margin=""0""
                      HorizontalAlignment=""Stretch"" VerticalAlignment=""Stretch""
                      HorizontalContentAlignment=""Center" "
                      Style=""{x:Null}""
                      Command =""pg:PropertyEditorCommands.ShowDialogEditor""
                      CommandParameter=""{Binding}"" />
        
                <TextBox Grid.Column=""1""
                         Text=""{Binding StringValue}""
                         ToolTip=""{Binding Value}""/>
        
        
              </Grid>
            </DataTemplate>
        ";
        
                    System.Windows.Markup.ParserContext context = new System.Windows.Markup.ParserContext();
                    context.XmlnsDictionary.Add("", "[URL="http://schemas.microsoft.com/winfx/2006/xaml/presentation%22"]http://schemas.microsoft.com/winfx/2006/xaml/presentation"[/URL]);
                    context.XmlnsDictionary.Add("x", "[URL="http://schemas.microsoft.com/winfx/2006/xaml%22"]http://schemas.microsoft.com/winfx/2006/xaml"[/URL]);
                    context.XmlnsDictionary.Add("pg", "[URL="http://schemas.denisvuyka.wordpress.com/wpfpropertygrid%22"]http://schemas.denisvuyka.wordpress.com/wpfpropertygrid"[/URL]);
                    System.Windows.DataTemplate template = (System.Windows.DataTemplate)System.Windows.Markup .XamlReader.Parse(xamlTemplate, context);
                    return template;
                }
        
                public override void ClearValue(System.Win dows.Controls.WpfPropertyGrid.PropertyItemValue propertyValue, System.Windows.IInputElement commandSource)
                {
                    if (propertyValue == null || propertyValue.IsReadOnly)
                    {
                        return;
                    }
                    propertyValue.StringValue = string.Empty;
                }
        
                public override void ShowDialog(System.Win dows.Controls.WpfPropertyGrid.PropertyItemValue propertyValue, System.Windows.IInputElement commandSource)
                {
                    System.Windows.Controls.WpfPropertyGri d.PropertyGrid propGrid = commandSource as System.Windows.Controls.WpfProper tyGrid.PropertyGrid;
                    if (propGrid == null) return;
        
                    NinjaTrader.Gui.Tools.NTWindow myWindow = new NinjaTrader.Gui.Tools.NTWindow();
                    myWindow.Width = 100;
                    myWindow.Height = 100;
                    myWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
                    bool? result = myWindow.ShowDialog();
                    propertyValue.StringValue = "success"; // change this string and compile, the ui does not see this change
                    propGrid.DoReload();
                    propGrid.RaiseEvent(new System.Windows .Controls.WpfPropertyGrid.PropertyValueChangedEven tArgs(System.Windows.Controls.WpfPropertyGrid.Prop ertyGrid.PropertyValueChangedEvent, propertyValue.ParentProperty, ""));
                }
            }
        }
        
        //use the custom property in a script
        
        [Display(Name = "TestProperty", GroupName = "Test")]
        [PropertyEditor("NinjaTrader.NinjaScript.AddOns.TestWPFWindowSelector")]
        public string TestProperty { get; set; }

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        571 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        331 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        549 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        549 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X