To attach a custom behavior to the TextBox, we need to add a reference to the System.Windows.Interactivity.dll file in our Silverlight project. This is available in Microsoft SDK’s Expression folder as below path:
c:\Program Files (x86)\Microsoft SDKs\Expression\Blend\Silverlight\v4.0\Libraries\System.Windows.Interactivity.dll
This dll provides various classes for element behavior, which can be customized for control specific event. One of the classes we are using in this article is the Behavior class. This class encapsulates state information and ICommands into the attachable object and performs some action when the control raises a specific event. E.g. If we attach a behavior with the TextBox and its TextChanged event, then during the execution when the end-user enters any text in the TextBox, the behavior associated with the TextChanged event will be automatically executed. Let us see some code:
Step 1: Open VS 2010 and create a new Silverlight project. Name the project as ‘SL4_TextBox_Interactivity_Behavior’. In this project, add a reference to ‘System.Windows.Interactivity’ dll.
Step 2: In the project, add a new class file and name it as ‘Data_Behavior_Classes.cs’. This file will contain the TextBox behavior class and data source classes as below:

Read more: dot net curry
QR: