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

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.
    Gaby V.NinjaTrader Customer Service

    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.
        Gaby V.NinjaTrader Customer Service

        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 tradingnasdaqprueba, Today, 03:42 AM
          9 responses
          34 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by manueldecastro, Today, 01:16 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by llanqui, Yesterday, 03:51 PM
          6 responses
          26 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by AlgoDreamer, Today, 12:39 PM
          2 responses
          9 views
          0 likes
          Last Post AlgoDreamer  
          Started by ninza33, Today, 12:31 PM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Working...
          X