Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to package/deliver xaml for custom control?

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

    How to package/deliver xaml for custom control?

    In my indicator / strategy code I use a custom UserControl. In NT 7 I used to simply embed the UserControl code into the indicator code as an inner class. Compilation and delivery was easy since the UserControl code was already in the indicator code being delivered.

    In NT 8, I am not sure how to accomplish the same thing. I prefer to not have a separate delivery of a .dll.

    Can anyone recommend a way to deliver (export) my custom control along with my indicators/strategies from the Ninja export tool?

    I tried putting the .cs and .xaml files in the same directories as other indicators but had a compile error: "The name "InitializeComponent()" does not exist in current context." This is referring to a method on base class UserControl. Which is weird because UserControl is in PresentationFramework.dll which is already referenced. So, stumped there.

    Do I need to deliver the xaml as baml and somehow load it from my code?

    NT folks: have you created a way to do this?
    Is this an AddOn? If so, please point to some documentation.

    Thanks for any suggestions.
    Gary

    #2
    Hello,

    There is some documentation along with XAML examples in the help guide addons section, but there is also a sample addon that was posted here: http://ninjatrader.com/support/forum...54&postcount=8

    This shows how to load the xaml page for use in the platforms tabbed window system.

    You can of course use that as you wish but it does show a way to load xaml and reference the controls in the xaml for used with NinjaTrader items.

    because the xaml is being read from file, you could theoretically as an end product just use a string of xaml that is included in the .cs file. That could then be read and generated at compile time without the need for an external xaml file.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Jesse,
      I am a bit confused by your statement:
      because the xaml is being read from file, you could theoretically as an end product just use a string of xaml that is included in the .cs file. That could then be read and generated at compile time without the need for an external xaml file.
      Did you really mean 'compile' time? If so, how do I get the NinjaTrader compiler to generate code from XAML at compile time?

      I suspect you meant load time. So I am guessing that in my indicator, in the Historical State, I would load the xaml? An then what? Would I cast the DependencyObject returned to be MyUserControl?

      Hope you can clear this up.

      Thanks,
      Gary

      Comment


        #4
        Hello,

        I am unsure when using the UserControl because that has the code behind .cs. The Addon example demonstrates a codebehinde-less way using a Page instead of a UserControl. in the code you load the xaml with, that basically becomes the code behind for the page you loaded.

        You are correct about the compile time, I did mean at load time as you are loading the xaml string and building it.

        regarding the casting, if you are using a Page, the code should be able to run as is. Your user control would need converted into a page without codebehind instead.

        as far as I am aware currently there is not a way to use code behind or usercontrols or is not documented at this time.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        6 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Started by alifarahani, Today, 09:40 AM
        6 responses
        41 views
        0 likes
        Last Post alifarahani  
        Working...
        X