Is that possible?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Adding button in Parameter window
Collapse
X
-
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.
-
here is the code that I came up with:
but when clicking on the button - nothing happensCode: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); } } }
Comment
-
Hello WHICKED,
While undocumented and not officially supported, i've slightly modified the example linked by Gaby.
LinkButtonCustomPropertyEditorsExample_NT8.zipChelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CaptainJack, 05-29-2026, 05:09 AM
|
0 responses
213 views
0 likes
|
Last Post
by CaptainJack
05-29-2026, 05:09 AM
|
||
|
Started by CaptainJack, 05-29-2026, 12:02 AM
|
0 responses
127 views
0 likes
|
Last Post
by CaptainJack
05-29-2026, 12:02 AM
|
||
|
Started by charlesugo_1, 05-26-2026, 05:03 PM
|
0 responses
145 views
0 likes
|
Last Post
by charlesugo_1
05-26-2026, 05:03 PM
|
||
|
Started by DannyP96, 05-18-2026, 02:38 PM
|
1 response
229 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
191 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|
Comment