Silverlight Tip of the Day #51 – How to Enable and Disable Controls
With Silverlight 2 RC0 Silverlight Controls can now be enabled/disabled via the property IsEnabled. This property is supported with all XAML controls found in the toolbox except those controls that are non-interactive (I.e. An ellipse, image, line, etc). By default all controls are enabled so you really only need to add this property if you want to set it to false in order to disable the control.
In addition to the property IsEnabled an event called IsEnableChanged is now available.
When setting IsEnabled=”false” the control is grayed out and will not respond to user interaction.
The following example has two sliders with the first one enabled and the second one disabled:
<Slider Canvas.Top="300" Width="300" Margin="20"></Slider>
<Slider IsEnabled="False" Canvas.Top="340" Width="300" Margin="20"></Slider>
Screen shot:
Thank you,
--Mike Snow
Subscribe in a reader