xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
xmlns:d='http://schemas.microsoft.com/expression/blend/2008'
xmlns:mc='http://schemas.openxmlformats.org/markup-compatibility/2006'
mc:Ignorable='d'
d:DesignWidth='640'
d:DesignHeight='480'>
TextBlock1
TextBlock2
TextBlock3
TextBlock4
Type the Name of a TextBlock from the above list.
//File: Page.xaml.cs
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace SilverlightApplication3
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
TextBlock tb = (TextBlock)LayoutRoot.FindName(ControlName.Text);
if (tb != null)
tb.FontSize = 20.0;
else {
ControlName.Foreground = new SolidColorBrush(Color.FromArgb(255, 200, 124, 124));
ControlName.Text = "Control not found! Please try again.";
}
}
private void ControlName_KeyDown(object sender, KeyEventArgs e)
{
ControlName.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
}
}
}