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

KeyEventArgs error

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

    KeyEventArgs error

    I have the below Addon script that is causing compilation error The type or namespace name 'KeyEventArgs' could not be found (are you missing a using directive or an assembly reference?) Please, what am I missing or doing wrong ?

    region Using declarations
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Markup;
    using NinjaTrader.Cbi;
    using NinjaTrader.Code;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.NinjaScript.Optimizers;
    #endregion

    namespace omoPop
    {​

    ...

    private void Form_KeyDown(object sender, KeyEventArgs e)
    {
    if (e.Key == Key.Escape)
    Close();
    }​

    ...

    }

    #2
    omololu You'll need to add another using statement: using System.Windows.Input;

    In cases like this where the error implies a missing reference (usually a "using" statement), it's often easy to find the culprit by searching for the particular item on the Microsoft C#/WPF sites. Google makes it straightforward: "C# WPF KeyEventArgs" ... and you'll quickly find the relevant assembly names to use.

    Thanks.
    Last edited by jeronymite; 12-18-2022, 05:26 PM.
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    Comment


      #3
      Hello omololu,

      Thanks for your post.

      This error message indicates that you are missing a using directive or assembly reference.

      jeronymite is correct. It is likely a missing using directive and a quick Google search could determine which using statement is missing. After doing a quick search for what jeronymite mentioned, we can see a search result that leads to a MSDN documentation about KeyEventArgs. KeyEventArgs requires a using statement of 'System.Windows.Input'.

      See this publicly available link for more information: https://learn.microsoft.com/en-us/do...owsdesktop-7.0

      Let me know if I may assist further.
      Brandon H.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by jeronymite View Post
        omololu You'll need to add another using statement: using System.Windows.Input;

        In cases like this where the error implies a missing reference (usually a "using" statement), it's often easy to find the culprit by searching for the particular item on the Microsoft C#/WPF sites. Google makes it straightforward: "C# WPF KeyEventArgs" ... and you'll quickly find the relevant assembly names to use.

        Thanks.
        Thanks for your response. Yes, the using System.Windows.Input stops the KeyEventArgs error. However, some new errors now emerge.

        Regards

        omololu

        Comment


          #5
          Originally posted by NinjaTrader_BrandonH View Post
          Hello omololu,

          Thanks for your post.

          This error message indicates that you are missing a using directive or assembly reference.

          jeronymite is correct. It is likely a missing using directive and a quick Google search could determine which using statement is missing. After doing a quick search for what jeronymite mentioned, we can see a search result that leads to a MSDN documentation about KeyEventArgs. KeyEventArgs requires a using statement of 'System.Windows.Input'.

          See this publicly available link for more information: https://learn.microsoft.com/en-us/do...owsdesktop-7.0

          Let me know if I may assist further.
          Brandon,

          Thank you for your response.

          Regards.

          omololu

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by lightsun47, Today, 03:51 PM
          0 responses
          5 views
          0 likes
          Last Post lightsun47  
          Started by 00nevest, Today, 02:27 PM
          1 response
          10 views
          0 likes
          Last Post 00nevest  
          Started by futtrader, 04-21-2024, 01:50 AM
          4 responses
          46 views
          0 likes
          Last Post futtrader  
          Started by Option Whisperer, Today, 09:55 AM
          1 response
          14 views
          0 likes
          Last Post bltdavid  
          Started by port119, Today, 02:43 PM
          0 responses
          10 views
          0 likes
          Last Post port119
          by port119
           
          Working...
          X