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

How to launch custom WPF Window from WPF PropertyGrid in ninjatrader

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

    How to launch custom WPF Window from WPF PropertyGrid in ninjatrader

    Hi there,

    I want to popup a custom WPF window to use as an editor from the indicator selector propertygrid. I have a working example in a stand alone WPF project using the System.Windows.Controls.WpfPropertyGrid.dll.
    It uses the following method:

    The property grid binds to the following object:

    Code:
    <pg:PropertyGrid SelectedObject="{StaticResource BusinessObject}" ShowReadOnlyProperties="True"/>
    The BusinessObject is as follows:

    Code:
        public class BusinessObject : INotifyPropertyChanged
        {
       ...
    
            [PropertyEditor(typeof(TestWindowPicker))]
            [PropertyOrder(4)]
            public string TestWindow
            {
                get { return testWindow; }
                set
                {
                    if (testWindow == value) return;
                    testWindow = value;
                    OnPropertyChanged("TestWindow");
                }
            }
        ...
      }
    }
    The TestWindowPicker is a simple class that launches the TestWindow and passes the value back and forth.

    Code:
        public class TestWindowPicker : PropertyEditor
        {
            public TestWindowPicker()
            {
                this.InlineTemplate = EditorKeys.FilePathPickerEditorKey;
            }
    
            public override void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource)
            {
                if (propertyValue == null) return;
                if (propertyValue.ParentProperty.IsReadOnly) return;
    
                TestWindow tw = new TestWindow();
    
                tw.TestString = propertyValue.StringValue;
    
                if (tw.ShowDialog() == true)
                {
                    propertyValue.StringValue = tw.TestString;
                }
            }
        }
    All pretty simple, and works great in the standalone project.

    I have tried this approach with a property in my Indicator class, and the property does show on the NT Indicator selection dialogue, however the ellipse button [...] to launch the TestWindow does not appear, instead there is just a textbox.

    The property in my indicator code is as follows:

    Code:
    [NinjaScriptProperty]
    [Display(Name = "Test_String", Description = "Test String", Order = 2, GroupName = "Parameters")]
    [PropertyEditor(typeof(TestWindowPicker))]
    public string Test_String
    { get; set; }
    Can you tell me what I am doing wrong here, and how to get it to show the ellipse button [...] to launch the TestWindow?

    Thank you for your time.

    #2
    Hello,

    Thank you for the post.

    I wanted to check if you have an export of the ninjaScript item you are currently testing that is not working. I reviewed what you have provided but It looks like I would need to generate a new indicator and try to configure it as you have which may be difficult in this case.

    If you can provide the sample you had used, I could review that and see if there is a way to get this working. I did try to copy the parts provided into a script but there are items missing like the TestWindow definition among other errors I can see.

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

    Comment


      #3
      Jesse,

      Thanks for the response. I have put together a sample indicator to allow you to replicate the issue, however I have noticed that I posted this in the NT7 forum, when it is an NT8 indicator I am working on. I will finish here and move to the following tread in the NT8 forum, and you can answer there ;-)


      Thanks for your time.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      44 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      20 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      179 views
      0 likes
      Last Post jeronymite  
      Started by ghoul, Today, 06:02 PM
      0 responses
      10 views
      0 likes
      Last Post ghoul
      by ghoul
       
      Started by DanielSanMartin, Yesterday, 02:37 PM
      2 responses
      13 views
      0 likes
      Last Post DanielSanMartin  
      Working...
      X