Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calling a WPF dialog from a strategy

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

    Calling a WPF dialog from a strategy

    I have a strategy in Version 7 that, when you click a button from the toolbar, it launches a Windows Forms dialog and I use that to manage trading at certain times.

    I would like to recreate that in Version 8 but I'm afraid my WPF skills are a little lacking - I have no idea how to do this. I enclosed a screen shot of a bare-bones strategy in version 7 that when you click the button, it launches a dialog with a single button that closes the dialog. This is what I'd like some help with with in version 8. In version 7, I created a Windows Forms project with all my controls on the dialog and copied and pasted them in a namespace in a strategy, passed a reference to the strategy and was able to communicate between the strategy and the dialog. CustomGUIv7 demonstrates this in the namespace GUI and the end of the file.

    I would think you would have to do something similar but when I create a WFP project I have no idea what to do with the XAML code. I've attached a similar bare bones version of a strategy for Version 8 that contains a button in the toolbar and the beginning of the code from the WPF project if someone can please tell me what to do with the XAML code from the VS 2015 CE project SessionMinder that is also attached. It should be the screen shot in Version 7. If someone could help me make a version 8 look like this, something launches an empty dialog box when the button is clicked, I can figure the rest out ; that is, I can put the rest of the controls on the dialog box.

    Thank you!!
    Attached Files

    #2
    Hello traderpards,

    Creating a new window in NT 8 is easier than NT7.

    For this use NTWindow to create the window.
    Then load window with content.
    Last open the window.

    Attached is an example of how to open a window from a button that is placed on the chart by a strategy.
    Attached Files
    Last edited by NinjaTrader_ChelseaB; 10-06-2015, 12:59 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Wow - I would never have figured that out...
      Thanks Chelsea!!

      Comment


        #4
        I don't have experience with WPF dynamic window. I have a question:
        Then load window with content.
        How I can get access to Label from strategy code?
        I found one way, sign up for an event
        Code:
                <Label Grid.Column="0" Grid.Row="0" [B]Loaded="Label_Loaded"[/B] Content="Custom window content here" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" FontSize="20" FontWeight="Bold" Foreground="White" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" />
        and then
        private void Label_Loaded(object sender, RoutedEventArgs e)
        {
        // ... Get label.
        var label = sender as Label;
        // ... Set date in content.
        label.Content = DateTime.Now.ToShortDateString();
        }
        any ideas?
        What you say about http://stackoverflow.com/questions/1...ynamic-content ?
        Last edited by alexr; 10-23-2015, 07:33 PM.

        Comment


          #5
          Hello alexr,

          Please see the posted example in post #2.

          Look for line 112 of the SampleAddonWindowTabPage.cs file.

          The label is named and then is grabbed with:
          askLabel = LogicalTreeHelper.FindLogicalNode(page, "AskLabel") as Label;
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Oh, really Thank you.

            ps. An example of the post #2 does not include the file SampleAddonWindowTabPage.cs But I understand what you mean.
            Attached Files

            Comment


              #7
              alexr,

              You are correct, this is not the same I was thinking of.

              I've attached the one (I thought I had posted) that is a bit more complicated.
              Attached Files
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by egordleo, Today, 05:50 AM
              0 responses
              4 views
              0 likes
              Last Post egordleo  
              Started by kevinenergy, 02-17-2023, 12:42 PM
              118 responses
              2,778 views
              1 like
              Last Post kevinenergy  
              Started by briansaul, Today, 05:31 AM
              0 responses
              9 views
              0 likes
              Last Post briansaul  
              Started by fwendolynlpxz, Today, 05:19 AM
              0 responses
              4 views
              0 likes
              Last Post fwendolynlpxz  
              Started by traderqz, Yesterday, 12:06 AM
              11 responses
              28 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Working...
              X