---
id: "M:cAlgo.API.Style.#ctor"
kind: "constructor"
type: "T:cAlgo.API.Style"
url: "https://help.ctrader.com/ctrader-algo/references/Controls/Styles/Style/Constructor/"
---

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

# Style constructor

Member of [Style](https://help.ctrader.com/ctrader-algo/references/Controls/Styles/Style/index.md).

## Style()

Initializes a new instance of Style class.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public Style()
```

Python:

```python
Style()
```

### Examples

C#:

```csharp
var style = new Style();
style.Set(ControlProperty.FontSize, 14);
style.Set(ControlProperty.Margin, 5);
var panel = new StackPanel();
panel.AddChild(new TextBlock { Text = "Balance", Style = style });
panel.AddChild(new TextBlock { Text = "Equity", Style = style });
Chart.AddControl(panel);
```

Python:

```python
style = Style()
style.Set(ControlProperty.FontSize, 14)
style.Set(ControlProperty.Margin, 5)
panel = StackPanel()
for text in ["Balance", "Equity"]:
    textBlock = TextBlock()
    textBlock.Text = text
    textBlock.Style = style
    panel.AddChild(textBlock)
api.Chart.AddControl(panel)
```

## Style(Style parentStyle)

Represents the parent style to be inherited by a desired style.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public Style(Style parentStyle)
```

Python:

```python
Style(parentStyle: Style)
```

### Parameters

- `parentStyle` (`Style`, Python `Style`):

### Examples

C#:

```csharp
var baseStyle = new Style();
baseStyle.Set(ControlProperty.FontSize, 12);
var warningStyle = new Style(baseStyle);
warningStyle.Set(ControlProperty.ForegroundColor, Color.Red);
Chart.AddControl(new TextBlock { Text = "Margin level is low", Style = warningStyle });
```

Python:

```python
baseStyle = Style()
baseStyle.Set(ControlProperty.FontSize, 12)
warningStyle = Style(baseStyle)
warningStyle.Set(ControlProperty.ForegroundColor, Color.Red)
textBlock = TextBlock()
textBlock.Text = "Margin level is low"
textBlock.Style = warningStyle
api.Chart.AddControl(textBlock)
```

