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);
}));

Comment