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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    102 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    144 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    71 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    125 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    79 views
    0 likes
    Last Post PaulMohn  
    Working...
    X