Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Use standard Settings popup in an AddOn?

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

  • NinjaTrader_Jesse
    replied
    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.

    Leave a comment:


  • jeronymite
    replied
    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.
    Simply, two AddOns treat XAML files differently during LoadXAML. One uses GetManifestResourceStream and reads the XAML at compile-time, not runtime. The other uses FileStream (because it cannot use GetManifestResourceStream) and reads the XAML at runtime not compile-time.

    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.

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello jeronymite,

    it seems I cannot use GetManifestResourceStream
    You won't be able to use embedded resources because you are not creating a C# dll, your code is part of the custom NinjaScript project which does not have any means to manage resources or additional files in that way. Your options include loading from file as the addon sample shows or building a dll externally as the alternate addon sample shows.

    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?
    Really the best solution is to just avoid xaml. Your addon is going to need to do the Content = LoadXAML(); no matter how you approach this to set its content. You can load that content from a .xaml file or build that content using C# or even just have a string of your xaml in the C# and pass that string to the parsing method. Once you are done making your addon you can just include the xaml as a string as the most simple option.


    I look forward to being of further assistance.
    Last edited by NinjaTrader_Jesse; 08-04-2020, 07:51 AM. Reason: edit

    Leave a comment:


  • jeronymite
    replied
    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.

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    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.".
    The website is not one you should be able to go to or access in a browser. This is a url that is defined in the assembly for the property grid dll.


    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.
    It works by telling the compiler what assembly to reference for the control you are using. This is the xaml equivalent of a using statement, you need to tell the xaml where that control is and the URL is how it is defined in this case. That is common for user controls defined in assemblies for WPF.



    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?
    Are you referring to the visual studio project example?

    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.

    Leave a comment:


  • jeronymite
    replied
    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.

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    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.




    Leave a comment:


  • jeronymite
    replied
    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.
    Attached Files
    Last edited by jeronymite; 08-02-2020, 03:54 PM.

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    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

    https://ninjatrader.com/support/help...t_overview.htm

    I look forward to being of further assistance.

    Leave a comment:


  • jeronymite
    replied
    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.

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello jeronymite,

    What settings popup are you referring to, are you asking about the general options window that you access from the control center?

    I look forward to being of further assistance.

    Leave a comment:


  • jeronymite
    started a topic Use standard Settings popup in an AddOn?

    Use standard Settings popup in an AddOn?

    Is there an example of how to use the standard NinjaTrader Settings popup mechanism in an AddOn?

    Thanks.

Latest Posts

Collapse

Topics Statistics Last Post
Started by Orion1504, Today, 11:59 AM
1 response
8 views
0 likes
Last Post NinjaTrader_Kate  
Started by z3trader, Today, 11:50 AM
5 responses
22 views
0 likes
Last Post NinjaTrader_ChristopherJ  
Started by Mykro, Today, 11:20 AM
3 responses
11 views
0 likes
Last Post NinjaTrader_BrandonH  
Started by RedDuke, Today, 10:49 AM
2 responses
6 views
0 likes
Last Post RedDuke
by RedDuke
 
Started by ChainsawDR, Today, 10:20 AM
2 responses
15 views
0 likes
Last Post NinjaTrader_Eleanore  
Working...
X