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.

        <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"/>

 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:


Author: Rupesh Nayak


Let us Connect!

Awards and Achievements

Red Herringcolor DeloitteFast50 DB ZInnov1   Nascome  DB Stpi

This site uses cookies. We respect your privacy.copyright (c) Mindfire Solutions 2007-2015. Login