Textblock. XAML
< Usercontrol X: Class = "Silverlightshortcontrol. textblock"
Xmlns = "Http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Xmlns: x = "Http://schemas.microsoft.com/winfx/2006/xaml" >
< Stackpanel Horizontalalignment = "Left" >
<! --
Value displayed on text-textblock
-->
< Textblock Text = "Textblock" />
<! --
Foreground-font color
-->
< Textblock Text = "Red textblock" Foreground = "Red" />
<! --
Use HTML encoding to directly display quotation marks and other special characters in XAML mode.
-->
< Textblock Text = "& Quot; textblock & quot; with quotation marks ;" />
<! --
Fontfamily-font
Fontsize-font size
Fontweight-font width [system. Windows. fontweights enumeration]
Fontstyle-font italics no [system. Windows. fontstyles enumeration]
Textdecorations-font underline [system. Windows. textdecorations enumeration]
Fontstretch-font spacing [system. Windows. fontstretches enumeration]
-->
< Textblock Text = "Textblock" Fontfamily = "" Fontsize = "36" Fontweight = "Bold" Fontstyle = "Italic" Textdecorations = "Underline" Fontstretch = "Normal" />
<! --
Textalignment-text arrangement [system. Windows. textalignment enumeration]
Run-Text Content
Linebreak-line break
Lineheight-height of each row
Textwrapping-text limit (whether to wrap the text if the limit is exceeded)
Nowrap-Never wrap
Wrap-line feed if the limit is exceeded
Linestackingstrategy-strategy for controlling Row Height
The Row Height of each row in maxheight-textblock is subject to the maximum value between the lineheight value and the row's own high value.
Blocklineheight-the line height of each line in textblock is subject to the lineheight value.
-->
< Textblock Verticalalignment = "Center" Textalignment = "Center" Lineheight = "10" Linestackingstrategy = "Maxheight" Width = "200" Textwrapping = "Nowrap" >
< Run Fontsize = "20" Foreground = "Maroon" Text = "Maroonmaroonmaroonmaroon" />
< Linebreak />
< Run Foreground = "Teal" Text = "Teal" />
< Linebreak />
< Run Fontsize = "30" Foreground = "Steelblue" Text = "Steelblue" />
</ Textblock >
< Textblock Verticalalignment = "Center" Textalignment = "Center" Lineheight = "10" Linestackingstrategy = "Blocklineheight" Width = "200" Textwrapping = "Wrap" >
< Run Fontsize = "20" Foreground = "Red" Text = "Redredredredredredredred" />
< Linebreak />
< Run Foreground = "Green" Text = "Green" />
< Linebreak />
< Run Fontsize = "30" Foreground = "Blue" Text = "Blue" />
</ Textblock >
</ Stackpanel >
</ Usercontrol >
Textbox. XAML
< Usercontrol X: Class = "Silverlightmediacontrol. textbox"
Xmlns = "Http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Xmlns: x = "Http://schemas.microsoft.com/winfx/2006/xaml" >
< Stackpanel Horizontalalignment = "Left" Width = "200" >
<! --
Value displayed in text-textbox
Borderthickness-Border width (pixel value: top, bottom, left, top, right, bottom)
Borderbrush-border color
-->
< Textbox Text = "Red box green bottom blue (really ugly )" Borderbrush = "Red" Borderthickness = "1, 5" Background = "Green" Foreground = "Blue" Margin = "6" />
<! --
Isreadonly-read-only or not
-->
< Textbox Text = "Read-Only textbox" Isreadonly = "True" Margin = "6" />
<! --
Acceptsreturn-whether to allow carriage return
Horizontalscrollbarvisibility-display status of the horizontal scroll bar
Verticalscrollbarvisibility-display status of the vertical scroll bar
Auto-automatically determines whether to display the scroll bar based on the width and height of the Textbox Control and the width and height of its content.
Disabled-do not display, but you can move or drag the keyboard or mouse in the displayed content to see the blocked content
Hidden-do not display, and cannot see the blocked content
Visible-display the scroll bar
-->
< Textbox Height = "50" Acceptsreturn = "True" Verticalscrollbarvisibility = "Auto" Margin = "6"
Text = "Multi-line text box 1 multi-line text box 2 multi-line text box 3 multi-line text box 4 multi-line text box 5 multi-line text box 6" />
<! --
Selectionchanged-events triggered when the selected text content changes
-->
< Textbox Height = "50" Acceptsreturn = "False" Margin = "5" Selectionchanged = "Textbox_selectionchanged"
Text = "Selected event multi-row text box 1 multi-row text box 2 multi-row text box 3" />
< Textblock Margin = "5" >
< Run > The selected text is: </ Run >
< Linebreak />
< Run X: Name = "Lblmsg" > </ Run >
</ Textblock >
</ Stackpanel >
</ Usercontrol >
Textbox. XAML. CS
Using System;
Using System. Collections. Generic;
Using System. LINQ;
Using System. net;
Using System. windows;
Using System. Windows. controls;
Using System. Windows. documents;
Using System. Windows. input;
Using System. Windows. Media;
Using System. Windows. Media. animation;
Using System. Windows. shapes;
Namespace Silverlightshortcontrol
{
Public Partial Class Textbox: usercontrol
{
Public Textbox ()
{
Initializecomponent ();
}
Private Void Textbox_selectionchanged ( Object Sender, routedeventargs E)
{
Lblmsg. Text = (system. Windows. Controls. textbox) sender). selectedtext;
}
}
}