Is that possible?
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!
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
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.Gaby V.NinjaTrader Customer Service
-
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); } } }
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 tradingnasdaqprueba, Today, 03:42 AM
|
9 responses
34 views
0 likes
|
Last Post Today, 01:32 PM | ||
Started by manueldecastro, Today, 01:16 PM
|
1 response
6 views
0 likes
|
Last Post Today, 01:30 PM | ||
Started by llanqui, Yesterday, 03:51 PM
|
6 responses
26 views
0 likes
|
Last Post Today, 01:17 PM | ||
Started by AlgoDreamer, Today, 12:39 PM
|
2 responses
9 views
0 likes
|
Last Post
by AlgoDreamer
Today, 12:56 PM
|
||
Started by ninza33, Today, 12:31 PM
|
1 response
5 views
0 likes
|
Last Post Today, 12:46 PM |
Comment