Thursday, June 14, 2007

Hello World Silverlight Example with <TextBlock> Tag

See Also: 1. Hello World Silverlight Example with <TextBlock> Tag
                   2How to display text with solid color brush
                   3. How to use gradient color brush in Silverlight

Download Source Code

If you don't have silverilght installed in your system first go through these articles otherwise please simply skip bellow three articles

Silverlight prerequisites and installation for web application development

Silverlight Development Tools & Software
Silverlight plug-in Inplace and Indirect installation, How to

Step 1. Open Visual Studio,

Step 2. Open New Silverlight Project

Now By Default you will get Page.xaml with the following code

<Canvas x:Name="parentCanvas"
xmlns="http://schemas.microsoft.com/client/2007"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Loaded="Page_Loaded"

x:Class="SilverlightProject1.Page;assembly=
ClientBin/SilverlightProject1.dll
"
Width="640"
Height="480"
Background="White"
>

</
Canvas>

Step 3. To display a text message in silveright canvas we have tag called <TextBlock>


Find the following modified code after adding <TextBlock> tag

<Canvas x:Name="parentCanvas"
xmlns="http://schemas.microsoft.com/client/2007"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Loaded="Page_Loaded"

x:Class="SilverlightProject1.Page;assembly=
ClientBin/SilverlightProject1.dll
"
Width="640"
Height="480"
Background="White"
>
<
TextBlock Text="Hello World" FontSize="50"
/>
</
Canvas>

Step 4. StepNow Run the Application By Pressing F5 with debugging or Ctrl+F5 without debugging.


 


Download Source Code

See Also: 1. Hello World Silverlight Example with <TextBlock> Tag
                   2How to display text with solid color brush
                   3. How to use gradient color brush in Silverlight