I added a custom button in chart trader, and I want to change the color when I click on the button.
I have a Bool i called it armLong to chnage from true to false dependent on clicks,
this is where i am creatign the button :
protected void CreateWPFControls()
{
chartWindow = Window.GetWindow(ChartControl.Parent) as Gui.Chart.Chart;
if (chartWindow == null)
return;
chartTraderGrid = (chartWindow.FindFirst("ChartWindowChartTraderControl") as Gui.Chart.ChartTrader).Content as System.Windows.Controls.Grid;
chartTraderButtonsGrid = chartTraderGrid.Children[0] as System.Windows.Controls.Grid;
lowerButtonsGrid = new System.Windows.Controls.Grid();
lowerButtonsGrid.RowDefinitions.Add(new System.Windows.Controls.RowDefinition());
lowerButtonsGrid.RowDefinitions.Add(new System.Windows.Controls.RowDefinition());
addedRow1 = new System.Windows.Controls.RowDefinition() { Height = new GridLength(60) };
addedRow2 = new System.Windows.Controls.RowDefinition() { Height = new GridLength(200) };
longButton = new System.Windows.Controls.Button()
{
Content = string.Format("Arm Long"),
Height = 25,
Margin = new Thickness(5,0,5,0),
Padding = new Thickness(0,0,0,0)
};
// change colors of the buttons
if(armLong == true){
longButton.Background = Brushes.Gray;
}else if (armLong == false) {
longButton.Background = Brushes.Lime;
}
longButton.Click += ARMLong;
lowerButtonsGrid.Children.Add(longButton);
if (TabSelected())
InsertWPFControls();
chartWindow.MainTabControl.SelectionChanged += TabChangedHandler;
}
protected void ARMLong(object sender, RoutedEventArgs e)
{
Print("------------------------------");
Print("Before Change : " + armLong);
armLong = !armLong;
Print("after Change : " + armLong);
ForceRefresh();
}
but It didnt update when i click on the button, the color stays the same :/
How can I fix this please
thank you in advance

Comment