Vectorlight News

  • Chat App Converted to HTML and JQuery
    Sep 08, 2011

    Converted from Silverlight to HTML and Javascript/JQuery is the Vectorlight Chat App. Login using your Vectorlight password to chat using your username and avatar.

  • HTML5 iPhone,Android Big Guns Tower Defense
    Jul 02, 2011

    Big Guns has made the leap from Windows Phone 7 (XNA) to HTML5 so you can now play it on your iPhone, Android and other HTML5 compatible devices.

  • HTML5 Games - Word Poppers and Batty
    Jun 04, 2011

    As the take-up of HTML5 quickens (74% of users currently have a browser capable of HTML5 Canvas) we present two more games for both your browser and mobile.

  • Big Guns Tower Defense on Windows Phone 7
    May 06, 2011

    Coming soon to Windows Phone 7 is an XNA port of the popular Vectorlight tower defense game Super Tower Defense. Whilst retaining many of the graphical and gameplay features of the original Silverlight game.

  • Wakacube WP7 Update
    Apr 26, 2011

    Released to the Windows Phone 7 marketplace today is Version 1.1 of Wakacube the 3D physics game of skill. Included in the update are more levels (30 in total) and new mode Wakatime which generates random crate structures to keep players entertained long after the levels have been completed.

  • Home Page News

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

dharmbhav posted

Woopie, sorry for my delayed response.



I did the following:



public BaseFloatingWindow(IRegionManager regionManager, IEventAggregator eventAggregator)


{


this.regionManager = regionManager;


InitializeComponent();


RegionManager.SetRegionManager(this, regionManager);


this.eventAggregator = eventAggregator;



closeWindowEvent = eventAggregator.GetEvent<CloseWindowEvent>();


closeWindowEvent.Subscribe(SubscribeToCloseEvent, true);


this.Closed+=new EventHandler(BaseFloatingWindow_Closed);


}


public void BaseFloatingWindow_Closed(object sender, EventArgs e)


{


foreach (object view in this.regionManager.Regions[regionName].Views)


{


if (((UserControl)view).DataContext is ViewModelBase)


{


((ViewModelBase)((UserControl)view).DataContext).KeepAlive = false;


}


regionManager.Regions[regionName].Remove(view);


}


Dispose();


}


private void SubscribeToCloseEvent(object obj)


{


if (regionName == obj.ToString())


{


closeWindowEvent.Unsubscribe(SubscribeToCloseEvent);


this.Close();


BaseFloatingWindow_Closed(new object(), new EventArgs());


}


}



Hope this helps.


Woopie posted

I found the bug in the latest version too.


@dharmbhav hopefully you get this but can you advise on the binding for MVVM please...


Thanks for the good library


dharmbhav posted

There seems to be an issue with v 5.3.3 of RichTextEditor. I wanted to use it in my Prism based MVVM application (with a little bit tweaking for Databinding) and it threw an object reference null exception. With v 5.2.7 it works fine now.


Sadly you havn't uploaded source code for v5.2.7 controls.


A good library though,


Thanks


hussam posted

How to Databind RichTextEditor?


paweb posted

How to implement superscript in RichTextBox but in web application ?


 

Post your Comments

Rate this: 

1 Star 2 Star 3 Star 4 Star 5 Star
12 Ratings / 3.2 Average

Tweets

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...