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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    54 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    131 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    73 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X