Introduction
This article explains how to create a CAPTCHA in WPF using the C# and XAML . CAPTCHA is an image of random words, like afs43, ahd4kj and so on . CAPTCHA stands for "Completely Automated Public Tuning Test" that determines whether or not the user is a human being.
Many users use automated programs to block other users from registering for a PGL account. In order to stop this blockings (by an automated program) we use a CAPTCHA. It is also used to prevent bots from registering for free email accounts and email addresses.
Step 1
First we create a WPF application using the following procedure:
- Open the Visual Studio.
- Select "New Project".
- Select the WPF Application.
- Name the project "Captcha in wpf".
- Click the "OK" button.

Step 2
Now we use some tools from the toolbox .
- So now go to "View" -> "Toolbox".
- Then Drag and Drop 1 textbox and 1 button onto the design view.

- Select the TextBox and press F4 .
- Change the background, font style, font weight, font size and foreground.
Step 3
After the changes, the final source code of the MainWindow.xaml is as in the following:
<Window x:Class="Ceptcha_in_WPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" Background="{x:Null}">
<Grid Background="{x:Null}" Visibility="Visible">
<TextBox Height="53" HorizontalAlignment="Left" FontSize="28" Foreground="Red" FontStyle="Italic" FontWeight="Heavy" Margin="86,105,0,0" Name="textBox1" VerticalAlignment="Top" Width="202" Background="{x:Null}" FontStretch="UltraCondensed"></TextBox>
<Button Content="Click" Height="31" HorizontalAlignment="Left" Margin="112,200,0,0" Name="button1" VerticalAlignment="Top" Width="161" Click="button1_Click" />
</Grid>
</Window>



Shalabh SaxenaPosted May 25, 2014, 8:47 AM
very easy to learn example for beginners. Much appreciated and now I am implementing this in MVVM.
Kiran Kumar TalikotiPosted Oct 3, 2013, 1:19 AM
Thank u.Very useful :)
Rohit MauryaPosted Sep 13, 2013, 2:04 AM
can u give simple example about validation of captcha in WPF