Transparency of text boxes

Created at 20 Apr 2023, 09:48
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
CT

ctid3999979

Joined 05.07.2021

Transparency of text boxes
20 Apr 2023, 09:48


Hi

Currently I use TextBoxes as a child to a StackPanel for displaying info in the chart window. I can't seem to be able to use transparency with it though. The new-ish indicator info at the top right does have this transparency though. What technique should I use to be able to have my text look like the indicator info text?

This is how I currently do it:

private TextBlock[] profitTextBlock = new TextBlock[4];
        private StackPanel profitPanel;


        Profits currentOpenProfits;
        Profits dailyProfits;

        protected override void Initialize()
        {

            currentOpenProfits = UpdateOpenPositionProfits();

            // Create StackPanel to contain the TextBlocks displaying the output
            profitPanel = new StackPanel
            {
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Bottom,
                BackgroundColor = Color.Black,
                Margin = 5
            };

            for (int i = 0; i < profitTextBlock.Count(); i++)
            {
                // Configure each of the TextBlocks
                profitTextBlock[i] = new TextBlock
                {
                    Text = "",
                    ForegroundColor = Color.White
                };
                profitPanel.AddChild(profitTextBlock[i]);
            }
            Chart.AddControl(profitPanel);
        }

Which results in this:

Ideally, it would have an opacity or alpha setting so I can adjust the level of transparency.


@ctid3999979
Replies

jim.tollan
20 Apr 2023, 12:03 ( Updated at: 20 Apr 2023, 14:56 )

RE:

Hello there - would this not work:

            var profitPanel = new StackPanel
            {
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Bottom,
                BackgroundColor = Color.Black,
                Opacity = 25,
                Margin = 5
            };

looks like the Opacity property would fit the bill... (?)


@jim.tollan