Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unhandled Exception in with error tooltip.

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

    Unhandled Exception in with error tooltip.

    Hi there,

    I am in the process of developing an Add-On, and want to do some input validation that is consistent with NT, so I was experimenting to see how you guys have implemented it and in the process came across the following unhandled exception:

    Replicate Steps:
    1. Start NinjaTrader 8.
    2. Click on the Workspaces menu on the Control Window and click on the "new" button.
    3. The New Workspace dialogue will open with a default value of "Untitled1". Delete this value and then press the "OK" button.
    4. This will cause a tooltip to appear with the error message.
    5. Click in the TextBox and the tooltip will disappear.
    6. Now move the mouse cursor out of the TextBox and then back over it. This will generate the unhandled exception.


    See attached pic.

    Interestingly.... as I continued my investigations I set a break point in an Add-On I wrote in the OnWindowCreated event and inspected the New Workspace window instance in the VS Watch Window and located the TextBox and attempted to serialize the TextBox.Style instance into XAML as I have done successfully with a number of other controls to see what you have done style and templating, in this case to see the Control Template for validation.

    When I did this I get the following error:
    "Initialization of 'System.Windows.Controls.AdornedElementPlaceholder ' threw an exception."

    This exception has an inner exception of:
    "Can only use AdornedElementPlaceholder as part of Template."

    I wondered if this was linked to the issue with the Validation Tooltip.... and so thought it might be worth posting.

    Regards,

    codeowl
    Attached Files
    Last edited by codeowl; 04-10-2016, 04:07 AM.

    #2
    Hello,

    That's a good catch, and I can see the same thing using your steps. I'll send a report to the team today to investigate further. (NTEIGHT-9666)

    Since you are playing with NinjaTrader controls in an AddOn, have you taken a look at the new AddOn Framework Example yet? This example shows how to add a variety of NinjaTrader controls (Instrument selectors, etc.). If not, you can check it out at the link below:

    Last edited by NinjaTrader_DaveI; 04-11-2016, 11:04 AM.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      Dave,

      Thanks for responding mate. Also thanks for the link to the AddOn Framework Example. That is brilliant, exactly the sort of thing we need. How could I have known about this if you hadn't told me? Eg; is there somewhere I can sign up to be notified of such things?

      Regards,

      codeowl

      Comment


        #4
        It would be nice if there were, but at this time the best I could do was create a forum post announcing it had been uploaded, which quickly got buried in the shuffle. I'm doing my best to spread the word to those interested in AddOn development, and we're also beefing up Help Guide documentation on AddOn development quite a bit, with links to this example in the new documentation.
        Dave I.NinjaTrader Product Management

        Comment


          #5
          Dave,

          Ok fair nuff mate... thanks for your efforts.

          Hey while we are on the subject of validation and help documentation, I have attached two screen shots. On is of the the New Workspace window when the validation is invoked for a required field, and the other is of my implementation of validation in an NTWindow.

          So with the New Workspace dialogue when the Ok button is pressed with no value in the textbox, the tooltip is automatically shown and positioned, and remains open till the user clicks in the textbox.

          With my implementation the tooltip does have the same foreground, background, and border colors, but is only shown on mouse over, and the textboxes have a red background.

          Is there a style you have used that I can assign to my textbox to create a consistent end user experience?

          My XAML is as follows:

          Code:
          <TextBox Name="tb_Name" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Stretch" Margin="0 5 0 10" MaxLength="100">
                      <TextBox.Text>
                          <Binding Path="Name" UpdateSourceTrigger="LostFocus">
                              <Binding.ValidationRules>
                                  <valRules:RequiredFieldValidationRule CustomMessage="Name is a required field"></valRules:RequiredFieldValidationRule>
                              </Binding.ValidationRules>
                          </Binding>
                      </TextBox.Text>
                  </TextBox>
          Also I just added a pic from the Slate Lite skin... it seems to only have a border color and not the blood read background in the textbox... are these styles set via the skin?

          Regards,

          codeowl
          Attached Files
          Last edited by codeowl; 04-14-2016, 05:30 AM. Reason: Adding pics

          Comment


            #6
            For the tooltip, we are instantiating a ToolTip object within an OnClick event handler in the xaml.cs code-behind file for the New Workspace window, and then setting the ToolTip's StaysOpen property to True. That is what causes the tooltip to remain in place until a user actually clicks somewhere.

            Code:
            				ToolTip newToolTip = new ToolTip
            				{
            					...
            
            					StaysOpen		= true,
            					IsOpen			= true,
            				};
            I should also note that rather than defining ValidationRules in XAML, we are handling the logic to check for an empty name in the xaml.cs code-behind, and then setting the Content property of the ToolTip within the instantiation of the ToolTip, all within the event handler.
            Last edited by NinjaTrader_DaveI; 04-14-2016, 09:02 AM.
            Dave I.NinjaTrader Product Management

            Comment


              #7
              For the background and border colors, those may not be defined in the skin, since none of our textboxes show those colors in the Slate Gray/Light skins. Have you tried setting the BorderBrush, Background, and possibly Foreground properties of the TextBox in your XAML?
              Dave I.NinjaTrader Product Management

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by CortexZenUSA, Today, 12:53 AM
              0 responses
              1 view
              0 likes
              Last Post CortexZenUSA  
              Started by CortexZenUSA, Today, 12:46 AM
              0 responses
              1 view
              0 likes
              Last Post CortexZenUSA  
              Started by usazencortex, Today, 12:43 AM
              0 responses
              5 views
              0 likes
              Last Post usazencortex  
              Started by sidlercom80, 10-28-2023, 08:49 AM
              168 responses
              2,265 views
              0 likes
              Last Post sidlercom80  
              Started by Barry Milan, Yesterday, 10:35 PM
              3 responses
              11 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Working...
              X