I found the solution
using System;
using System.ComponentModel;
using System.Windows.Media;
using System.Windows.Controls;
using System.Windows.Documents;
namespace SilverlightApplicationTextTransform
{
public partial class MainPage : UserControl, INotifyPropertyChanged
{
#region ViewModelProperty: MainContent
private object _mainContent;
public object MainContent
{
get
{
return _mainContent;
}
set
{
_mainContent = value;
OnPropertyChanged("MainContent");
}
}
#endregion
public MainPage()
{
InitializeComponent();
DataContext = this;
}
private char[] textToDisplay = null;
private int length = 0;
private void textBoxTextToDisplay_TextChanged(object sender, TextChangedEventArgs e)
{
textToDisplay = textBoxTextToDisplay.Text.ToCharArray();
length = textToDisplay.Length;
TextBlock tb = new TextBlock();
tb.FontFamily = new FontFamily("Courier");
tb.FontSize = 15;
int fontSize = 15;
Run[] runLabel = new Run[length];
bool par = false;
if (length % 2 == 0)
{
par = true;
}
for (int i = 0; i < length / 2; i++)
{
runLabel[i] = new Run();
runLabel[i].Text = Convert.ToString(textToDisplay[i]);
runLabel[i].FontSize = fontSize;
tb.Inlines.Add(runLabel[i]);
if ((par == true) && (i == (length / 2) - 1))
{
}
else
{
fontSize += 3;
}
}
for (int i = length / 2; i < length; i++)
{
runLabel[i] = new Run();
runLabel[i].Text = Convert.ToString(textToDisplay[i]);
runLabel[i].FontSize = fontSize;
tb.Inlines.Add(runLabel[i]);
fontSize -= 3;
}
MainContent = tb;
}
#region INotifiedProperty Block
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
#endregion
}
}
And the XAML:
<sdk:Label Height="Auto" Name="labelDisplay" Width="Auto">
<ContentControl Content="{Binding MainContent}"/>
</sdk:Label>