Using Properties in Custom Controls
When you create a custom Silverlight control extension, you can bind the attributes of user-interface (UI) elements to the values that a developer enters in the Visual Studio screen designer (Figure C-1).
Figure C-1. Property values that developers can modify
Chapter 19 (Listing 19-7) included a custom control that binds to values from the property sheet. An excerpt of this code is shown in Listing C-1.
Listing C-1. Using property names
The data-binding syntax in this code includes the property names Width, Height, TextAlignment, and VerticalAlignment. You can use these property names in your XAML and .NET code. The purpose of this appendix is to show you a list of property names that you can use in your code.
The appearance properties that are shown next are “opt-out” properties. This refers to properties that LightSwitch automatically shows in the property sheet:
The other group of property names that you can refer to are “opt-in” properties. By default, these properties don’t show up in Visual Studio’s properties sheet. To make them appear, you need to set the property’s EditorVisibility value to PropertySheet in your custom control’s LSML file, as shown in Listing C-2. Refer to Chapter 19 (Listing 19-23) to see a full example of a custom control’s LSML file.
Listing C-2. Making properties visible in Visual Studio’s properties sheet
The two EditorVisibility values that you can set are the following:
Here’s a full list of opt-in properties that you can use:
To see a built-in control that implements two of these opt-in properties, take a look at the label control. If you add a label control to a screen and open the properties sheet, you can find options to set the ShowAsLink and FontStyle properties.