Announcement

Collapse
No announcement yet.

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.
      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

      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 Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          574 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          332 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          553 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X