AutoEventWireup="true" CodeFile="text.aspx.cs" Inherits="tutorials_controls_tutorialtemplate_Text"
Title="Silverlight TextBlock element tutorials : DotNetFunda.com" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHeader" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderForTitleAndIntro" runat="Server">
<table width="100%" cellpadding="2" cellspacing="0">
<tr valign="top" class="ArticleTitle">
<td style="padding-left: 10px;" valign="middle">
Silverlight TextBlock element tutorials</td>
</tr>
<tr>
<td class="ArticleContents">
Silverlight supports TextBlock that allows you to place text into your Silverlight objects.
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
</table>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderForContents" runat="Server">
<!-- START - Demo Section -->
<table class="DemoPlaceHolder" border="1" cellpadding="2" cellspacing="4">
<tr>
<td class="DemoTitle" style="width:50%;">
DEMO : TextBlock element
</td>
<td align="right">
<a class="DemoShowSource" href="../../misc/codeviewer/default.aspx?pagename=~/tutorials/silverlight/text.aspx"
target="_blank">Show Source Code</a>
</td>
</tr>
<tr valign="top">
<td>
To simply write any text inside the Silverlight object, you need to specify the <span class="DemoCP">Text</span> property of the TextBlock element.
<pre>
<Canvas
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextBlock Text="DotNetFunda.com" />
</Canvas>
</pre>
</td>
<td>
<!-- START - Define XAML content. -->
<script type="text/xaml" id="xamlScript1">
<?xml version="1.0"?>
<Canvas
xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextBlock Text="DotNetFunda.com" />
</Canvas>
</script>
<!-- END - Define XAML content. -->
<div id="pluginHost1">
<script language="javascript" type="text/javascript">
createSilverlightPlugin('pluginHost1', '200', '150', '#xamlScript1')
</script>
</div>
</td>
</tr>
<tr valign="top">
<td>
<b>Common properties of TextBlock element</b><br />
<b>FontSize</b> allows you to specify the font size of the text. <br />
<b>FontFamily</b> allows you to specify the font names, separated by comma. If the 1st couldn't find, Silverlight will render the text in next font. <br />
<b>FontStyle></b> allows you to specify the style of the text.<br />
<b>FontWeight</b> allows you to specify the weight of the text.<br />
<b>FontStretch</b> allows you to specify the stretch pattern of the text.<br />
<b>Foreground</b> allows you to specify the color of the text.<br />
<b>Opacity</b> allows you to specify the alpha or transparency of the text.
<pre>
<Canvas
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextBlock FontSize="20" FontFamily="Arial, Verdana"
FontStyle="Oblique" FontWeight="Bold" Canvas.Top="20" Canvas.Left="20"
FontStretch="ExtraCondensed" Foreground="Red" Opacity=".5" >
DotNetFunda.com
</TextBlock>
</Canvas>
</pre>
</td>
<td>
<!-- START - Define XAML content. -->
<script type="text/xaml" id="xamlScript2">
<?xml version="1.0"?>
<Canvas
xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextBlock FontSize="20" FontFamily="Arial, Verdana"
FontStyle="Oblique" FontWeight="Bold" Canvas.Top="20" Canvas.Left="20"
FontStretch="ExtraCondensed" Foreground="Red" Opacity=".5" >
DotNetFunda.com
</TextBlock>
</Canvas>
</script>
<!-- END - Define XAML content. -->
<div id="pluginHost2">
<script language="javascript" type="text/javascript">
createSilverlightPlugin('pluginHost2', '200', '200', '#xamlScript2')
</script>
</div>
</td>
</tr>
<tr valign="top">
<td>
<b>Run / LineBreak</b> <br />
<b>Run</b>element allows you to change the look of specific text inside the TextBlock. <br />
<b>LineBreak</b> allows you to place the text into next line. New line text can be specified inside Run element, otherwise TextBlock properties will be applied to the text.
<pre>
<Canvas
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextBlock FontSize="15" FontFamily="Arial, Verdana" Canvas.Left="5"
FontStyle="Oblique" FontWeight="Bold" Canvas.Top="20"
FontStretch="ExtraCondensed" Foreground="Red" Opacity=".75" >
Silverlight <Run FontSize="25" Foreground="Blue" FontStyle="Normal">Tutorials</Run>
<LineBreak />
<Run FontFamily="Trebuchet MS, Arial" Foreground="Blue"
FontStyle="Normal" FontWeight="Thin">
written by
</Run>
Sheo Narayan
</TextBlock>
</Canvas> </pre>
</td>
<td>
<!-- START - Define XAML content. -->
<script type="text/xaml" id="xamlScript3">
<?xml version="1.0"?>
<Canvas
xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextBlock FontSize="15" FontFamily="Arial, Verdana" Canvas.Left="5"
FontStyle="Oblique" FontWeight="Bold" Canvas.Top="20"
FontStretch="ExtraCondensed" Foreground="Red" Opacity=".75" >
Silverlight <Run FontSize="25" Foreground="Blue" FontStyle="Normal">Tutorials</Run>
<LineBreak />
<Run FontFamily="Trebuchet MS, Arial" Foreground="Blue" FontStyle="Normal" FontWeight="Thin">
written by
</Run>
Sheo Narayan
</TextBlock>
</Canvas>
</script>
<!-- END - Define XAML content. -->
<div id="pluginHost3">
<script language="javascript" type="text/javascript">
createSilverlightPlugin('pluginHost3', '200', '200', '#xamlScript3')
</script>
</div>
</td>
</tr>
</table>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderFooter" runat="Server">
</asp:Content>
Go Top