Latest News

  • Super Tower Defense 2 Game
    Sep 03, 2010

    New to the games section is Super Tower Defense 2. Featuring more maps, new units and bigger explosions.

  • Super Cards Online Multiplayer Game
    Aug 13, 2010

    Released today in the games section is the new Super Cards multiplayer card game. The aim of the game is to get rid of all your playing cards before your opposition.

  • Silverlight Online Chat
    Jul 24, 2010

    Today we launch the new Silverlight Live Chat application demonstrating the Liquid RichTextBox and Emoticon replacements.

  • New Super Shoot Em Up 2 Game
    Jun 29, 2010

    Added to the Games section is the new Super Shoot 'Em Up 2 game. Take control of your tank with the aim to defeat the computer controlled opponents. Features all new weapons, levels and Battle Mode!

  • Silverlight 4 Controls V5.3.2 Released
    Jun 28, 2010

    This release contains several fixes raised in the forums.

The RichTextArea Control

This new Silverlight 4 only control allows you to input RichText into your Silverlight application.  Here is a simple example of its use, complete with some simple formatting commands.

We have created an enhanced version of the RichTextArea control which enables you to Load and Save the content as basic HTML.  This control is available to download with all the source code here.



<UserControl x:Class="RichTextArea.MainPage"
    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:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White" Width="300" Height="300">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Border Grid.Row="0" BorderThickness="1" BorderBrush="#8b919f">
            <StackPanel Orientation="Horizontal">
                <StackPanel.Background>
                    <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                        <GradientStop Color="#ffffff" Offset="0.0" />
                        <GradientStop Color="#e3e8f4" Offset="0.5" />
                        <GradientStop Color="#cfd7eb" Offset="0.5" />
                        <GradientStop Color="#e9ecfa" Offset="1.0" />
                    </LinearGradientBrush>
                </StackPanel.Background>
                <StackPanel Orientation="Horizontal" Margin="4">
                    <ComboBox x:Name="selectFontFamily" Width="155" Height="23" Margin="0 0 2 0" SelectionChanged="SelectFontFamily_ItemSelected">
                        <ComboBoxItem Content="Arial" FontSize="14" FontFamily="Arial" IsSelected="True" />
                        <ComboBoxItem Content="Arial Black" FontSize="14" FontFamily="Arial Black" />
                        <ComboBoxItem Content="Comic Sans MS" FontSize="14" FontFamily="Comic Sans MS" />
                        <ComboBoxItem Content="Courier New" FontSize="14" FontFamily="Courier New" />
                        <ComboBoxItem Content="Lucida Sans Unicode" FontSize="14" FontFamily="Lucida Sans Unicode" />
                        <ComboBoxItem Content="Times New Roman" FontSize="14" FontFamily="Times New Roman" />
                        <ComboBoxItem Content="Trebuchet MS" FontSize="14" FontFamily="Trebuchet MS" />
                        <ComboBoxItem Content="Verdana" FontSize="14" FontFamily="Verdana" />
                    </ComboBox>
                    <ComboBox x:Name="selectFontSize" Width="45" Height="23" Margin="0, 0, 10, 0" SelectionChanged="SelectFontSize_ItemSelected">
                        <ComboBoxItem Content="6" />
                        <ComboBoxItem Content="7" />
                        <ComboBoxItem Content="8" />
                        <ComboBoxItem Content="9" />
                        <ComboBoxItem Content="10" />
                        <ComboBoxItem Content="11" />
                        <ComboBoxItem Content="12" IsSelected="True" />
                        <ComboBoxItem Content="13" />
                        <ComboBoxItem Content="14" />
                        <ComboBoxItem Content="15" />
                        <ComboBoxItem Content="16" />
                        <ComboBoxItem Content="17" />
                        <ComboBoxItem Content="18" />
                        <ComboBoxItem Content="20" />
                        <ComboBoxItem Content="22" />
                        <ComboBoxItem Content="24" />
                        <ComboBoxItem Content="26" />
                        <ComboBoxItem Content="28" />
                        <ComboBoxItem Content="36" />
                        <ComboBoxItem Content="48" />
                        <ComboBoxItem Content="72" />
                    </ComboBox>
                    <Button x:Name="makeBold" Width="24" Height="23" Margin="0 0 2 0" Click="MakeBold_Click">
                        <TextBlock x:Name="boldText" Text="B" FontFamily="Arial" FontSize="14" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" />
                    </Button>
                    <Button x:Name="makeItalic" Width="24" Height="23" Margin="0 0 2 0" Click="MakeItalic_Click">
                        <TextBlock x:Name="italicText" Text="I" FontFamily="Arial" FontSize="14" FontStyle="Italic" HorizontalAlignment="Center" VerticalAlignment="Center" />
                    </Button>
                    <Button x:Name="makeUnderline" Width="24" Height="23" Margin="0 0 10 0" Click="MakeUnderline_Click">
                        <TextBlock x:Name="underlineText" Text="U" FontFamily="Arial" FontSize="14" TextDecorations="Underline" HorizontalAlignment="Center" VerticalAlignment="Center" />
                    </Button>
                </StackPanel>
            </StackPanel>
        </Border>
        <RichTextArea x:Name="rta" Grid.Row="1" />
    </Grid>
</UserControl>


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 RichTextArea
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void SelectFontFamily_ItemSelected(object sender, EventArgs e)
        {
            if (selectFontFamily != null)
            {
                rta.Selection.SetPropertyValue(TextElement.FontFamilyProperty, new FontFamily(((ComboBoxItem)selectFontFamily.SelectedItem).FontFamily.Source));
            }
        }

        private void SelectFontSize_ItemSelected(object sender, EventArgs e)
        {
            if (selectFontSize != null)
            {
                rta.Selection.SetPropertyValue(TextElement.FontSizeProperty, double.Parse(((ComboBoxItem)selectFontSize.SelectedItem).Content.ToString()));
            }
        }

        private void MakeBold_Click(object sender, RoutedEventArgs e)
        {
            rta.Selection.SetPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
        }

        private void MakeItalic_Click(object sender, RoutedEventArgs e)
        {
            rta.Selection.SetPropertyValue(TextElement.FontStyleProperty, FontStyles.Italic);
        }

        private void MakeUnderline_Click(object sender, RoutedEventArgs e)
        {
            rta.Selection.SetPropertyValue(TextElement.TextDecorationsProperty, TextDecorations.Underline);
        }
    }
}


Here we show how to format text using the basic formatting commands such as Bold, Italic and Underline as well as Font Family and Size.

Your Comments

No comments found.

 

Post your Comments

Rate this page: 

1 Star 2 Star 3 Star 4 Star 5 Star
10 Ratings / 2.8 Average

Ultimate Gamers

  • 1 Gh0sT
  • 2 stig
  • 3 dhoz
  • 4 seyhmusss
  • 5 RadiateLogic
  • 6 bigblue531
  • 7 janso
  • 8 DutchRemco
  • 9 Gendibal
  • 10 dan

  • See the full chart here!

Silverlight Controls

  • Rich TextBox

    Create and edit rich content with this slick and expandable Rich TextBox...

  • TreeView

    This easy to use TreeView comes with drag and drop, sorting, searching and much more...

  • Context Menu

    You too can have cool popup context menus in your Silverlight applications...

  • Resizable Dialog

    Draggable and resizable popup dialogs are what serious Silverlight developers need...

  • Spell Checker

    Real-time spell checking in Silverlight? We did it first here...