How to implement style in Silverlight ?



Hi
Style in Silverlight is similar to CSS of asp.net page. Silverlight style allows us to define a common set of formatting characteristics and apply them throughout our application to ensure the consistency in page design.

Here i have created style for button like this

<UserControl x:Class="SilverlightApplication3.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml&quot;
xmlns:d="http://schemas.microsoft.com/expression/blend/2008&quot;
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
mc:Ignorable="d" Height="300" Width="400">
<UserControl.Resources>
<Style x:Key="ButtonCSS" TargetType="Button">
<Setter Property="Foreground" Value="SeaGreen"/>
<Setter Property="FontSize" Value="28"/>
<Setter Property="Height" Value="50"/>
<Setter Property="Width" Value="200"/>
<Setter Property="FontStyle" Value="Italic"/>
</Style>
</UserControl.Resources>

<Grid>
<Button Content="Submit" Style="{StaticResource ButtonCSS}"/>
</Grid>

</UserControl>

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.