---
id: "T:cAlgo.API.Style"
kind: "class"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/Controls/Styles/Style/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# Style (class)

Represents the style of a chart control.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public class Style
```

## Examples

C#:

```csharp
using cAlgo.API;

namespace cAlgo
{
    // This sample shows how to use control style to change a group of controls style instead of setting each control properties separatly
    public partial class StyleSample : Indicator
    {
        protected override void Initialize()
        {
            var style = new Style();

            style.Set(ControlProperty.Margin, 5);
            style.Set(ControlProperty.ForegroundColor, Color.Blue);
            style.Set(ControlProperty.FontSize, 14);
            style.Set(ControlProperty.Width, 100);

            var stackPanel = new StackPanel
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                BackgroundColor = Color.Gold,
                Orientation = Orientation.Vertical
            };

            for (var i = 0; i < 10; i++)
            {
                stackPanel.AddChild(new TextBlock
                {
                    Text = "Text Block #" + i,
                    Style = style
                });
            }

            Chart.AddControl(stackPanel);
        }

        public override void Calculate(int index)
        {
        }
    }
}
```

Python:

```python
import clr
clr.AddReference("cAlgo.API")

from cAlgo.API import *

class Test():
    def initialize(self):
        style = Style()
        style.Set(ControlProperty.Margin, 5)
        style.Set(ControlProperty.ForegroundColor, Color.Blue)
        style.Set(ControlProperty.FontSize, 14)
        style.Set(ControlProperty.Width, 100)

        stackPanel = StackPanel()
        stackPanel.HorizontalAlignment = HorizontalAlignment.Center
        stackPanel.VerticalAlignment = VerticalAlignment.Center
        stackPanel.BackgroundColor = Color.Gold
        stackPanel.Orientation = Orientation.Vertical

        for i in range(10):
            textBlock = TextBlock()
            textBlock.Text = f"Text Block #{i}"
            textBlock.Style = style
            stackPanel.AddChild(textBlock)

        api.Chart.AddControl(stackPanel)
```

config.json:

```json
{
  "AccessRights": "None",
  "TimeZone": "UTC",
  "IsOverlay": true
}
```

## Constructors

- `public Style()` — Initializes a new instance of Style class. [details](https://help.ctrader.com/ctrader-algo/references/Controls/Styles/Style/Constructor/index.md)
- `public Style(Style parentStyle)` — Represents the parent style to be inherited by a desired style. [details](https://help.ctrader.com/ctrader-algo/references/Controls/Styles/Style/Constructor/index.md)

## Methods

- `public object Get(ControlProperty property)` — Gets the chart object style for the specified ControlProperty. [details](https://help.ctrader.com/ctrader-algo/references/Controls/Styles/Style/Get/index.md)
- `public object Get(ControlProperty property, ControlState state)` — Gets the chart control style for the specified ControlProperty and ControlState. [details](https://help.ctrader.com/ctrader-algo/references/Controls/Styles/Style/Get/index.md)
- `public void Set(ControlProperty property, object value, ControlState state)` — Provides data for the chart control Style for the specified ControlProperty and the ControlState. [details](https://help.ctrader.com/ctrader-algo/references/Controls/Styles/Style/Set/index.md)
- `public void Set(ControlProperty property, object value)` — Sets the chart control Style for the specified ControlProperty. [details](https://help.ctrader.com/ctrader-algo/references/Controls/Styles/Style/Set/index.md)

