Thanks.
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
Use standard Settings popup in an AddOn?
Collapse
X
-
Hi Jesse,
I want to set settings anywhere in the same manner as Properties windows popup when setting them in most facilities of NT8. For example, setting Properties of a window, or configuring workspaces, etc. Essentially, using the common window style used to set Properties in many different places.
Thanks.
Comment
-
Hello jeronymite,
The only guidance I could provide on this would be the windows you see in the platform are all NTWindow. You can make the styled windows, this is shown in the addon sample however the controls for properties windows and how they are designed is not something I have access to. I can say that they are just WPF windows like the rest of the tools in the platform. You can design something similar but you would need to use WPF controls to do so. It looks like in some windows the standard property grid is being used and in others they are custom WPF controls. The property grid is not something we support to develop with but you can add it, there are other posts on the forum about that if you search for PropertyGrid
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
I came across the attached PropertyGrid example today while scanning the Forum for something else. It was offered by a NinjaTrader Support person. And do you think I can find the original post to refer to? ... Sadly, no. So, I cannot say thanks or identify the person (although ChelseaB comes to mind for some reason). Nevertheless, the sample works well, compiled from scratch.
I have modified it to work within an AddOn-only context (no Indicator involved). In the process, I wonder why the original actually works, because the XAML refers to xmlns:wpfPropertyGrid="http://schemas.denisvuyka.wordpress.com/wpfpropertygrid" and that URL claims to no longer exist. Why would the XAML work at all if that is so?
In any case, is there an updated version of this example?
Additionally, how can one modify the code so that the XAML file becomes included as a resource, in like manner to that which is used in loading an NTTabPage as per the AddOnFramework example. There, GetManifestResourceStream is used to load the XAML file at compile time and subsequently the file is no longer required to be part of the distribution. How can one do the same in this context?
Thanks.Last edited by jeronymite; 08-02-2020, 03:54 PM.
Comment
-
Hello jeronymite,
Where are you seeing the error you mentioned? Is that a compile/runtime error or something in visual studio? That would likely be expected in visual studio and would also be expected if you don't have the dll for the property grid referenced.
Including files as a resource is not something you can do with the NinjaTrader export. You would need to include it in the templates folder as mention in this document: https://ninjatrader.com/support/help...lyzerTemplates
You can then update the path in your code to reflect where that extracts to in the templates folder.
The alternative would be to use only C# code to construct your WPF controls instead of loading/parsing the xaml file. The addon samples we provide are for simplicity as most WPF beginners will use Xaml syntax or the designer in visual studio to make xaml content. That means it loads from file a xaml page and then makes a control out of that which is used as the content. You can use C# code to just construct the same objects and content rather than loading the xaml/parsing it into an object. There are examples online on this subject in relation to C# and xaml design, you could search for "c# wpf create button programmatically" as one example. Xaml is fairly easy in how you can construct it in C# code, everything has the same names/properties and is structured nearly the same as the xaml is tiered.
I look forward to being of further assistance.
JesseNinjaTrader Customer Service
Comment
-
Thanks, Jesse.
I am familiar with C# code-behind and am happy to construct "embedded XAML" or "XAML equivalent" C# to create relevant structures.
My concern is with the use of a reference to schema in XAML that do not appear to exist: http://schemas.denisvuyka.wordpress.com/wpfpropertygrid
Entering that URL in a browser takes one to Wordpress where it states "denisvuyka.wordpress.com is no longer available. The authors have deleted this site.".
That being so, how does that work in the example provided? It clearly is necessary, since removing it causes the XAML to fail, whereas with it as written, the XAML works as expected.
In respect of resources, is it possible to read the XAML file and treat it in the same manner as NTTabPage in the AddOnFramework; i.e. once read, the file is no longer required in the distribution because it has essentially been compile-in?
As always, thanks for your kind assistance.
Comment
-
Hello jeronymite,
Entering that URL in a browser takes one to Wordpress where it states "denisvuyka.wordpress.com is no longer available. The authors have deleted this site.".
That being so, how does that work in the example provided? It clearly is necessary, since removing it causes the XAML to fail, whereas with it as written, the XAML works as expected.
In respect of resources, is it possible to read the XAML file and treat it in the same manner as NTTabPage in the AddOnFramework; i.e. once read, the file is no longer required in the distribution because it has essentially been compile-in?
The addon sample basic works by reading the xaml file every time it is created.
The visual studio project compiles the xaml into the dll because you compile outside of NinjaTrader using visual studio. NinjaTrader does not compile .xaml files so you would instead read them and parse them if you want the structure to be created into an object.
I look forward to being of further assistance.
JesseNinjaTrader Customer Service
Comment
-
Thanks, as always, Jesse.
I understand how the schema statements work in general, but I wasn't aware that the URL is essentially "embedded" in the dll as a form of reference, rather than representing something accessed in its own right as a URL. Thanks for that additional insight. It also helps to make sense of the behaviour I observe.
As for the AddOnFramework use of the XAML file, I am not using Visual Studio. I have placed the XAML file in the AddOns folder where the C# AddOn source is located. The XAML file is read there when I compile in the NinjaScript Editor. The XAML file is read once only at compile time, not again at runtime. This is the behaviour I wish to duplicate in the Property Grid example, rather than having the file read at runtime, as the example has it. Because I am creating an NTWindow, not an NTTabPage, it seems I cannot use GetManifestResourceStream and instead I use a FileStream.
How can I achieve the same effective behaviour for the Property Grid code as for the AddOnFramework code, namely that the file is read once only at compile time and not again at runtime?
Thanks.
Comment
-
Hello jeronymite,
it seems I cannot use GetManifestResourceStream
How can I achieve the same effective behaviour for the Property Grid code as for the AddOnFramework code, namely that the file is read once only at compile time and not again at runtime?
I look forward to being of further assistance.
JesseNinjaTrader Customer Service
Comment
-
Thanks, Jesse.
Forgive me if I am not clear in what I'm explaining. Let me try to summarise once more.
Two very similar ways to produce AddOns treat the XAML file differently:- AddOnFramework creates an NTTabPage. It reads a XAML file once only, at compile-time, with LoadXAML() using GetManifestResourceStream. The file is not read again at runtime. This is verified by running the AddOn to show that the XAML was read in its original form, then stopping the AddOn, changing the XAML file, and rerunning the AddOn (NO recompile) and seeing that despite changes to the XAML file, the original XAML specification is what is used.
- The PropertyGrid example creates an NTWindow, not an NTTabPage. It too reads XAML using LoadXAML, but since it cannot use GetManifestResourceStream, it must use a FileStream. The XAML is read at runtime, not at compile-time. This can be verified by running the AddOn to show the XAML was read in its original form, then stopping the AddOn, changing the XAML file, rerunning the AddOn (NO recompile) and seeing that all changes to the XAML file are now seen.
How can I use GetManifestResourceStream or an equivalent in the AddOn that is not creating an NTTabPage?
I know I can embed XAML and there are other ways to avoid the need to even have a separate XAML file, but given that AddOnFramework demonstrates a way to have a read-once-at-compile-time XAML file, I would like to know how to to do that when the AddOn is not creating an NTTabPage.
Thanks.
Comment
-
Hello jeronymite,
That method is part of the tab page so you wouldn't be able to use it outside of that context. You would need to use one of the other means to load xaml if you are not using a tab page.
In general it really shouldn't make any difference here, the addon will still present the UI, you are just loading the xaml in a different way. For distribution it is still going to be suggested to include your xaml as a variable in string form for simplicity or to use the templates folder like described in the help guide.
Please let me know if I may be of further assistance.
JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by pickles1774, 02-28-2024, 12:34 PM
|
2 responses
33 views
0 likes
|
Last Post
by pickles1774
Today, 05:25 AM
|
||
Started by Allwest, Yesterday, 10:25 PM
|
2 responses
21 views
0 likes
|
Last Post Today, 04:18 AM | ||
Started by bmandonlidal, Today, 03:34 AM
|
0 responses
1 view
0 likes
|
Last Post
by bmandonlidal
Today, 03:34 AM
|
||
Started by LincolnOrtiz, Today, 03:10 AM
|
0 responses
2 views
0 likes
|
Last Post
by LincolnOrtiz
Today, 03:10 AM
|
||
Started by Dr Kerry, Today, 02:03 AM
|
0 responses
4 views
0 likes
|
Last Post
by Dr Kerry
Today, 02:03 AM
|
Comment