Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding button in Parameter window

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

    Adding button in Parameter window

    I am looking to put a button in the parameters that someone can click on and it would then open up a URL link.

    Is that possible?

    #2
    Hello WHICKED,

    Thank you for your post.

    This is possible, however it is not officially supported. We do have an unsupported example that you can reference:

    Hey everyone, I'm currently trying to figure out a way on how to add a button on settings panel. I saw a post where they created a button but it's on the Chart Panel. Is there anyway I can create button on Settings Panel?


    Note: This requires a reference to C:\Program Files\NinjaTrader 8\bin\System.Windows.Controls.WpfPropertyGrid.dll

    This thread will remain open for any users who may want to assist or provide an unsupported solution.
    Last edited by NinjaTrader_Gaby; 04-26-2024, 01:12 PM.

    Comment


      #3
      here is the code that I came up with:

      Code:
      public class ShowHelp : System.Windows.Controls.WpfPropertyGrid.PropertyEditor
          {
              public ShowHelp()
              {
                  InlineTemplate = CreateTemplate();
              }
          
              System.Windows.DataTemplate CreateTemplate()
              {
                  const string xamlTemplate = @"
                      <DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
                                    xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
                          <Grid>
                              <Grid.ColumnDefinitions>
                                  <ColumnDefinition Width='*'/>
                              </Grid.ColumnDefinitions>
          
                              <Button x:Name='helpButton' Grid.Column='0' Content='Click here for help'
                                      HorizontalAlignment='Center' VerticalAlignment='Center'/>
                          </Grid>
                      </DataTemplate>";
          
                  var context = new ParserContext();
                  context.XmlnsDictionary.Add("", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
                  context.XmlnsDictionary.Add("x", "http://schemas.microsoft.com/winfx/2006/xaml");
          
                  System.Windows.DataTemplate template = (System.Windows.DataTemplate)System.Windows.Markup.XamlReader.Parse(xamlTemplate, context);
          
                  // Add event handler dynamically after the template is loaded
                  template.LoadContent(); // This loads the content defined by the DataTemplate
                  if (template.LoadContent() is FrameworkElement rootElement && rootElement.FindName("helpButton") is Button helpButton)
                  {
                      helpButton.Click += OnHelpButtonClick;
                  }
          
                  return template;
              }
          
              private void OnHelpButtonClick(object sender, System.Windows.RoutedEventArgs e)
              {
                  string url = "http://google.com";
                  try
                  {
                      System.Diagnostics.Process.Start(url);
                      System.Diagnostics.Debug.WriteLine("Browser launched successfully.");
                  }
                  catch (Exception ex)
                  {
                      System.Diagnostics.Debug.WriteLine("Failed to launch browser: " + ex.Message);
                  }
              }
          }​
      but when clicking on the button - nothing happens

      Comment


        #4
        Hello WHICKED,

        As this code is unsupported, we unfortunately cannot provide support for debugging however this thread will remain open for any forum users who may want to assist.

        Comment


          #5
          Hello WHICKED,

          While undocumented and not officially supported, i've slightly modified the example linked by Gaby.
          LinkButtonCustomPropertyEditorsExample_NT8.zip
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

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