Adding Functionality to an Existing Control

If you simply want to add behavior to an existing control you can inherit from that control, rather than create a whole new control from scratch. For example, let's say you want the text in a TextBox control to automatically be selected when the control gains the focus, enabling the user to easily overwrite the existing text, instead of the default behavior in which the cursor is simply placed at the end of the existing text.

You have two main options you could use to achieve this behavior:

  1. Create an action (as described in Chapter 10) that is triggered when the control gets the focus and selects the text as required. (Alternatively, you could create a behavior instead.) You can then apply that action ...

Get Pro Business Applications with Silverlight 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.