Software Technology Tips

In Silverlight2.0 controls can be customized in a similar way to that of using CSS in HTML,Silverlight 2.0 allows us to define a group of properties as a Custom Style and later on apply the Custom Style to a controls or more controls.The styles are defined as resource at the application level (app.xaml) or a page level (e.g. Page.xaml).

For example we can define the style in app.xaml page as follows.

<Application.Resources>
        <Style x:Key="MyTextBoxStyle" TargetType="TextBox">
            <Setter Property="FontFamily" Value="Verdana"/>
            <Setter Property="Margin" Value="10,0,10,0"/>
            <Setter Property="FontSize" Value="20"/>
            <Setter Property="Height" Value="25"/>
            <Setter Property="Width" Value="150"/>
            <Setter Property="TextWrapping" Value="Wrap"/>
        </Style>
</Application.Resources>

 The above style targets to TextBox controls. Now , you can set the style to the Style property of the TextBox control in the page level as follows.

<TextBox x:Name="txtName" Style="{StaticResource MyTextBoxStyle}" />


Related Tags:

Silverlight

Author: Rupesh Nayak

Silverlight

Let us Connect!

iso 9001 QA25 Red Herring STPI D&B Fastest Growing SME 2013 Award zinnov Nasscom

copyright (c) Mindfire Solutions 2007-2014. Login