## Стили и темы
Стили
```
```
```
```
![](./img/1.jpg)
## Value
```
```
```
```
![](./img/2.jpg)
## TargetType
```
```
```
```
![](./img/3.jpg)
1 КНОПКА СЕРАЯ
```
```
![](./img/4.jpg)
## Определение обработчиков событий с помощью стилей
```
```
```
private void Button_Click(object sender, RoutedEventArgs e)
{
Button clickedButton = (Button)sender;
MessageBox.Show(clickedButton.Content.ToString());
}
```
![](./img/5.jpg)
## Наследование стилей и свойство BasedOn
```
```
![](./img/6.jpg)
Стили в C#
```
Style buttonStyle = new Style();
buttonStyle.Setters.Add(
new Setter
{
Property = Control.FontFamilyProperty,
Value = new FontFamily("Verdana")
});
buttonStyle.Setters.Add(
new Setter
{
Property = Control.MarginProperty,
Value = new Thickness(10)
});
buttonStyle.Setters.Add(
new Setter
{
Property = Control.BackgroundProperty,
Value = new SolidColorBrush(Colors.DarkOliveGreen)
});
buttonStyle.Setters.Add(
new Setter
{
Property = Control.ForegroundProperty,
Value = new SolidColorBrush(Colors.HotPink)
});
button1.Style = buttonStyle;
button2.Style = buttonStyle;
```
![](./img/7.jpg)