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 kinfxhk, 07-13-2026, 10:18 AM
    0 responses
    57 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 09:50 AM
    0 responses
    39 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 07:21 AM
    0 responses
    45 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-11-2026, 02:11 AM
    0 responses
    35 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    153 views
    0 likes
    Last Post SalmaTrader  
    Working...
    X