Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnButtonClick doesn't exist on current context

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

    OnButtonClick doesn't exist on current context

    Hi ,
    when I create a button within strategy code, it gave me the following error message "The name OnButtonClick doesn't exist on current context" due to the line of code highlighted in Green below. However, this same line of code works from another strategy. What is that ???

    Thanks for your help !

    else if (State == State.Historical)
    {
    if (UserControlCollection.Contains(myGrid))
    return;​
    Dispatcher.InvokeAsync((() =>
    {
    myGrid = new System.Windows.Controls.Grid
    {
    Name = "MyCustomGrid", HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Top
    };

    System.Windows.Controls.ColumnDefinition column1 = new System.Windows.Controls.ColumnDefinition();
    System.Windows.Controls.ColumnDefinition column2 = new System.Windows.Controls.ColumnDefinition();

    myGrid.ColumnDefinitions.Add(column1);
    myGrid.ColumnDefinitions.Add(column2);

    longButton = new System.Windows.Controls.Button();
    longButton.Name = "LongButton";
    longButton.Click += OnButtonClick;
    System.Windows.Controls.Grid.SetColumn(longButton, 0);
    System.Windows.Controls.Grid.SetColumn(shortButton , 1);

    myGrid.Children.Add(longButton);
    myGrid.Children.Add(shortButton);

    UserControlCollection.Add(myGrid);
    }));​

    #2
    Hello,

    Thank you for your post.

    Do you have the OnButtonClick event handler code included in your script?

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    72 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    39 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X