So powerful is WPF that you can write, in less than 20 lines of markup (with zero code behind), a simple text editor... with spell checking!
All you need do is put the following XAML into your favourite text editor and compile:
<Window x:Class="SimpleXAMLTextEditor.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="SimpleXAMLTextEditor" Height="300" Width="300">
<DockPanel>
<Menu DockPanel.Dock="Top">
<MenuItem Header="Edit">
<MenuItem Command="Cut" Header="_Cut" />
<MenuItem Command="Copy" Header="C_opy" />
<MenuItem Command="Paste" Header="_Paste" />
</MenuItem>
</Menu>
<ToolBarTray DockPanel.Dock="Top">
<ToolBar>
<Button Command="Cut" Content="Cut" />
<Button Command="Copy" Content="Copy" />
<Button Command="Paste" Content="Paste" />
</ToolBar>
</ToolBarTray>
<TextBox SpellCheck.IsEnabled="True" />
</DockPanel>
</Window>
This produces a very simple application:
No code is required because the WPF team have already implemented the standard edit commands[*] for the TextBox and RichTextBox controls. You also get spelling for free by just adding one attribute.
Do the WPF team rock or what!
[*] For more on commands check out my previous post on the subject.


3 comments:
Wow thats a great example, Ta.
Great example!
Great Example!
Post a Comment