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

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.
    JesseNinjaTrader Customer Service

    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; }
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by fwendolynlpxz, Today, 05:19 AM
        0 responses
        1 view
        0 likes
        Last Post fwendolynlpxz  
        Started by traderqz, Yesterday, 12:06 AM
        11 responses
        27 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by PaulMohn, Today, 03:49 AM
        0 responses
        8 views
        0 likes
        Last Post PaulMohn  
        Started by inanazsocial, Today, 01:15 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Jason  
        Started by rocketman7, Today, 02:12 AM
        0 responses
        11 views
        0 likes
        Last Post rocketman7  
        Working...
        X