Introduction
In this Blog you will see how to create user control for upper case textbox
Step 1
Add class1.cs to your current project as UC_UpperCase_TextBox
Figure 1:Add Class
Step 2
Inherit this class with textbox like
public class UC_UpperCase_TextBox : TextBox
Step 3
Create TextChanged Event for this control
- public UC_UpperCase_TextBox()
- {
- this.TextChanged += new TextChangedEventHandler(UC_UpperCase_TextBox_TextChanged);
- }
Inside TextChanged event put code for convert text in Upper Case
- void UC_UpperCase_TextBox_TextChanged(object sender, TextChangedEventArgs e)
- {
- var tb = (TextBox) sender;
- var selectionStart = tb.SelectionStart;
- var selectionLength = tb.SelectionLength;
- tb.Text = tb.Text.ToUpper();
- tb.SelectionStart = selectionStart;
- tb.SelectionLength = selectionLength;
- }

Figure 2: Code
Step 5
You can use it as a control in .xaml like:
- <my2:UC_UpperCase_TextBox Grid.Row="1" Grid.Column="1" Margin="2,3" Height="23" Text="{Binding TITLE,Mode=TwoWay}" HorizontalAlignment="Stretch" VerticalAlignment="Center" x:Name="txt_Title" MaxLength="1024" />

SubashPosted Apr 11, 2017, 12:37 AM
Nice share sir thank you
Narasimha Reddy ChennupalliPosted Jul 12, 2015, 10:22 AM
Nice one..
Santhakumar MunuswamyPosted Jul 11, 2015, 3:39 AM
Good one
Gowtham RajamanickamPosted Jul 11, 2015, 2:03 AM
Good one...