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

NTGrid negative values red foreground

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

    NTGrid negative values red foreground

    I've been searching for a solution to the seemingly simple task of displaying NTGrid negative currency values in red... searched the Infragistics forum, and got the XDGNegativeCellColorsCase VS solution from this post... but the Xaml gets spat out by the XamlReader when I include it in my Addon.

    Trying the Xaml approach, I have included
    Code:
    xmlns:local="clr-namespace:XDGNegativeCellColorsCase"
    but my XamlReader throws this exception:
    Code:
    System.Windows.Markup.XamlParseException:
    ''Cannot create unknown type '{clr-namespace:XDGNegativeCellColorsCase}IsNegativeConverter'.'
    Line number '27' and line position '10'.'
    Same code works just fine in the XDGNegativeCellColorsCase VS solution - only fails in my Addon. So I've been trying to achieve the same in code-behind, and removed the above Xaml.

    I have an IValueConverter declared as
    Code:
    namespace XDGNegativeCellColorsCase
    {[INDENT]public class IsNegativeConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null)
            {
                if (((int)value) < 0)
                {
                    return true;
                }
               else
               {
                   return false;
               }
            }
            else
            {
                 return false;
            }
       }[/INDENT][INDENT]   public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
       {[/INDENT]
              throw new NotImplementedException();
             }
        }
    }
    but seems I can't get the required triggers, setters etc in my code to make it all work.

    Any help appreciated,
    T.
    Last edited by tgn55; 11-12-2020, 08:00 PM.

    #2
    Hello tgn55,

    Thank you for the post.

    Unfortunately this is an area which we have really no resources or documentation as the control being used is ultimately a third party control. For the value converter part of your question that may be a good question to post on the infragistics forum to ask if there is a way to use this in a C# only way without having to put it in xaml. I am not aware of any samples or related information on manipulating the grid cells.

    If you had this working in visual studio you may want to try using the addon visual studio project to see if you can use what you had working in that context: https://ninjatrader.com/support/help...t_overview.htm

    Please let me know if I may be of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hey Jesse... yeah I know it's not something I expect NT Support to cover... was hoping some other developers might have an answer.

      My Addon started with the example provided by NT... so it has the LoadXaml method. Not at all clear why it barfs on Xaml code which is clearly kosher... since it works fine in the VS solution I got from Infragistics. At the end of the day, this is low priority.. only cosmetic to had red negatives.

      I have one other important issue recently discovered with my Addon... but it is so very different to this thread, I'll start a new one.

      Cheers,
      T.

      Comment


        #4
        Hello tgn55,

        Just to try and provide more context here, the LoadXaml method is likely failing because that won't know about the custom dll's and namespaces you used in that use case. Its just parsing xaml using the C# XamlReader.Load method. For the given error Cannot create unknown type, you could search online for "C# XamlReader.Load cannot create unknown type" to get some suggestions. I don't know if any would work for that use case but you can try something like what is shown in this public stackoverflow answer. Getting that to work in exported assemblies or all use cases may some testing if something you locate does work. https://stackoverflow.com/questions/...amlreader-load

        The xamlreader is a C# concept and is a more advanced concept because you are not using the compiler to compile the xaml but doing that in runtime instead. There are likely a lot of ways that can be used however NinjaTrader uses the most simple approach here to parse simple tools. If you need compiled xaml/normal C# features and loading you can use the addon project i linked in the last post, the addon visual studio edition. That would be another route to try because that will allow you to compile xaml and may let you use the namespace needed.

        I have one other important issue recently discovered with my Addon... but it is so very different to this thread, I'll start a new one.
        I appreciate that, its best to focus on single issues in threads so we can refer back to that info more easily.

        Please let me know if I may be of further assistance.

        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks Jesse... the StackOverflow link helped... I now don't get the error about creating an unknown type... solution was to add "assembly=NinjaTrader.Custom" to the xmlns:local declaration.

          That said... I still can't get it working from the Xaml code I borrowed from the VS solution referenced on the Infragistics forum here. Likewise, trying to modify the style in code, which I successfully did to get date/time formatting customised, also still is not working. Sigh...

          Oh... BTW - I repeat I AM using (one of) the demo VS solutions... I think it was based on AddonShell.

          I will keep playing with this in the background... if I find a solution, others might like to know how to do it. I will post a new thread on the other issue in a few minutes... it is "under-the-bonnet" stuff.

          Cheers,
          T.


          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by yertle, Today, 08:38 AM
          2 responses
          7 views
          0 likes
          Last Post yertle
          by yertle
           
          Started by dappa, Today, 09:18 AM
          0 responses
          1 view
          0 likes
          Last Post dappa
          by dappa
           
          Started by bill2023, Yesterday, 08:51 AM
          4 responses
          22 views
          0 likes
          Last Post bltdavid  
          Started by trilliantrader, Today, 08:16 AM
          3 responses
          9 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by NinjaTrader_ChelseaB, 01-08-2017, 06:59 PM
          79 responses
          19,662 views
          5 likes
          Last Post zrobfrank  
          Working...
          X