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

Author custom property editors

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

    Author custom property editors

    In

    Code:
    https://ninjatrader.com/support/helpGuides/nt8/NT%20HelpGuide%20English.html?using_a_typeconverter_to_custo.htm
    the attached example (https://ninjatrader.com/support/help...verter_NT8.zip)

    shows some examples on how to customize the property grid. in particular I am referring to those where the attribute PropertyEditorAttribute is used:

    Code:
            [TypeConverter(typeof(FriendlyBoolConverter))] // Converts the bool to string values
            [PropertyEditor("NinjaTrader.Gui.Tools.StringStandardValuesEditorKey")] // Create the combo box on the property grid
            [Display(Name = "Friendly bool", Order = 1, GroupName = "Use Case #3")]
            public bool FriendlyBool
            { get; set; }
    
    
    
            [TypeConverter(typeof(FriendlyEnumConverter))] // Converts the enum to string values
            [PropertyEditor("NinjaTrader.Gui.Tools.StringStandardValuesEditorKey")] // Enums normally automatically get a combo box, but we need to apply this specific editor so default value is automatically selected
            [Display(Name = "Friendly Enum", Order = 8, GroupName = "Use Case #4")]
            public MyEnum EnumValue
            { get; set; }
    
    
            // Note: All these DisplayAttribute properties are required
            // Prompt is used to set what displays in the property grid and during mouseover
            [XmlIgnore]
            [Display(Name = "List values", GroupName = "Use Case #5", Order = 9, Prompt = "1 value|{0} values|Add value...|Edit value...|Edit values...")]
            [PropertyEditor("NinjaTrader.Gui.Tools.CollectionEditor")] // Allows a pop-up to be used to add values to the collection, similar to Price Levels in Drawing Tools
            [SkipOnCopyTo(true)]
            public Collection<PercentWrapper> MyListValues
            {
                get
                {
                    return myListValues;
                }
                set
                {
                    myListValues = new Collection<PercentWrapper>(value.ToList());
                }
            }
    ​
    However, I couldn't find documentation on how to use that attribute (PropertyEditorAttribute).

    By analysing the code and introspecting assemblies with VS Object Browser and ILSpy, I inferred that the attribute allows to assign to a property an editor different from the default one.
    This seems to be based on the Infragistics WpfPropertyGrid custom control.
    However, the custom editors used in the examples are classes in the NinjaTrader.Gui.Tools namespace.
    What I want to do is to develop custom WPF controls and use them as editor for properties in custom indicators/strategies.
    For example, I could have a complex custom strategy parameter (not a simple string, boolean, number or enum), and I would like to see a button in the property grid. Clicking on that button, a WPF dialog would open, allowing the user to view/edit in a custom way the value of the property.
    It seems that all the available editors in NinjaTrader.Gui.Tools are inheriting from
    System.Windows.Controls.WpfPropertyGrid.PropertyEd itor
    , but this class is not exposed to NinjaScript use.

    Is it possible to simply use a natural local WPF control with visual studio (https://learn.microsoft.com/en-us/do...orkdesktop-4.8) and then make NinjaTrader use it for a property when showing the property grid of an indicator or strategy?

    I know that another way could be writing an AddOn, however if what I am asking was possible it would be much easier to implement.
    Last edited by franco.tiveron; 11-15-2023, 11:14 PM.
    franco.tiveron
    NinjaTrader Ecosystem Vendor - franco.tiveron

Latest Posts

Collapse

Topics Statistics Last Post
Started by Segwin, 05-07-2018, 02:15 PM
14 responses
1,789 views
0 likes
Last Post aligator  
Started by Jimmyk, 01-26-2018, 05:19 AM
6 responses
837 views
0 likes
Last Post emuns
by emuns
 
Started by jxs_xrj, 01-12-2020, 09:49 AM
6 responses
3,293 views
1 like
Last Post jgualdronc  
Started by Touch-Ups, Today, 10:36 AM
0 responses
13 views
0 likes
Last Post Touch-Ups  
Started by geddyisodin, 04-25-2024, 05:20 AM
11 responses
63 views
0 likes
Last Post halgo_boulder  
Working...
X