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

wpf UserControl

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

    wpf UserControl

    So,

    I would like to add a wpf User Control to my project.

    Using VS 2015 I can edit the NinjaTrader.custom.csproj and add such a control from the wizard. Using Visual Studio the build will go through with no error.

    When I then try to compile this from within NT8 I get errors and the code cannot be compiled.
    Here a typical error.

    NinjaScript File Error Code Line Column
    UserControl2.cs The type 'NinjaTrader.Custom.Strategies.UserControl2' already contains a definition for 'button' CS0102 11 49

    Problem is probably related to the fact that VS compiles xaml files to a Page. I am not sure how the NT8 works.
    Please give instructions on how to compile.

    regards
    Andreas

    #2
    Hello Andreas,

    Creating a custom control would be general C# and would not be specific to NinjaScript.

    This is outside of what is supported by NinjaTrader Support, however, NinjaTrader_Jesse was kind enough to put together an example for another forum member.



    This thread will remain open for any community members that would like to assist.

    You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello ChelseaB,

      thank you, but the example avoids the code-behind management of Visual Studio 2015.
      The point of using wpf controls is that you can easily design and modify them in Visual Studio. Using your aproach the xaml is loaded but all events and objects have to be assigend by hand and created beforehand in code.

      Basically I do still report a compiler problem of NT8 and I would like to understand better why xaml files are not compiled at all.

      Another error in the NY8 compiler is that .cs files in the Custom\bin\obj\Debug directories are automatically included in the compile. But in the list of directories or files the subfolder \obj does not even show up.

      So you can compile in VS2015, this will then generate a.g.i.cs and a.g.cs files from a.cs in the obj\Debug subfolder while VS2015 generates a correct NinjaTrader.custom.dll.

      However it seems that NT8 does not accept an externally compiled NinjaTrader.custom.dll and will always recompile internally.

      Having the obj\Debug leftover from a VS2015 compile the NT8 compile get also through, but the code is then not working as the function
      System.Windows.Application.LoadComponent(this, resourceLocater);
      will fail. Tried a few variants , but any load of the xaml fails.






      System.Uri resourceLocater = new System.Uri("/NinjaTrader.Custom;component/strategies/usercontrol2.xaml", System.UriKind.Relative);



      #line 1 "..\..\..\Strategies\UserControl2.xaml"
      System.Windows.Application.LoadComponent(this, resourceLocater);

      Comment


        #4
        Hello zweistein,

        I do not know if this advice will serve your purpose, but I would program the wpf usercontrol inside Visual Studio. I would then copy and paste the usercontrol dll into the bin/Custom folder and add the dll to the references so that I can use the usercontrol in my scripts.

        The only reason I can think of for wanting to develop the usercontrol within NinjaTrader is to export it protected along with the ninjascript.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cre8able, Today, 03:20 PM
        1 response
        9 views
        0 likes
        Last Post cre8able  
        Started by fiddich, Today, 05:25 PM
        0 responses
        3 views
        0 likes
        Last Post fiddich
        by fiddich
         
        Started by gemify, 11-11-2022, 11:52 AM
        6 responses
        804 views
        2 likes
        Last Post ultls
        by ultls
         
        Started by ScottWalsh, Today, 04:52 PM
        0 responses
        4 views
        0 likes
        Last Post ScottWalsh  
        Started by ScottWalsh, Today, 04:29 PM
        0 responses
        9 views
        0 likes
        Last Post ScottWalsh  
        Working...
        X