• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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.

    https://ninjatrader.com/support/foru...519#post508519

    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 priceisking, Today, 11:30 AM
        0 responses
        4 views
        0 likes
        Last Post priceisking  
        Started by traderpards, Today, 11:09 AM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by HinduMVP, Today, 10:49 AM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Tyler  
        Started by sisenberg, Today, 10:18 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_PatrickG  
        Started by akuntysh, Today, 04:56 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X