---
title: "How can style elements be applied? (similar to a CSS file/skins)"  
description: "How can style elements be applied? (similar to a CSS file/skins)"  
author: "Amit Singh"  
published: 2011-03-17  
updated: 2020-09-22  
canonical: https://www.mindstick.com/interview/427/how-can-style-elements-be-applied-similar-to-a-css-file-skins  
category: "silverlight"  
tags: ["silverlight"]  
reading_time: 1 minute  

---

# How can style elements be applied? (similar to a CSS file/skins)

Styles elements are supported in the form of application resources. An app.xaml file can be created containing an application resource Xml construct. The target type for each style is set to the control on which the style needs to be applied. \
\
**App.xaml:** \

```
<Application.Resource> <Style x:Key="MyBorder" TargetType="Border"> <setter property="width" value="5"> </style>
```

\
**Page.xaml:** \

```
<Border Style="{StaticResource MyBorder}"> ... </Border>
```

## Answers

### Answer by Amit Singh

Styles elements are supported in the form of application resources. An app.xaml file can be created containing an application resource Xml construct. The target type for each style is set to the control on which the style needs to be applied. \
\
**App.xaml:** \

```
<Application.Resource> <Style x:Key="MyBorder" TargetType="Border"> <setter property="width" value="5"> </style>
```

\
**Page.xaml:** \

```
<Border Style="{StaticResource MyBorder}"> ... </Border>
```


---

Original Source: https://www.mindstick.com/interview/427/how-can-style-elements-be-applied-similar-to-a-css-file-skins

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
