Archive

Archive for February, 2011

How to set ‘IsEnabled’ Property for Stackpanel in Silverlight

February 2, 2011 1 comment

Hi,

Its been long time, I have updated my blog. There are couple of reasons for not getting updated because of my work @ my new company. My new company as provided me an opportunity to work on technologies like silverlight and sharepoint.  I’m very thank ful for this. I wish my breadth of technology awareness and handon gets improved on day to day basis. Recently I came  across with problem of ” How to disable the stackpanel and its descedant controls”. By Default some container/layout control does not have “IsEnabled” property. To disable all controls inside the stackpanel, we need to add “IsEnabled” property for each control, which is not advisable and laborious one. We can perform another way by extending stackpanel/grid class with Custom Dependency Property of type “Boolean”.  Add new property to custom stackpanel /custom grid and disable all visualchildrens of childrens inside the layout control(stackpanel,grid).  i.e Stackpanel.Getvisualchildren() and disable each child control.

There is another simple way of disabling stackpanel/Grid/Dockpanel by adding “ContentControl” and wraps the stackpanel XAML code inside “ContentControl” .Since ContentControl is having “IsEnabled” property , we can Bind datacontext or set IsEnabled to false for disabling all controls inside the stackpanel. This is simplest for performing disabling of stackpanel/grid/dockpanel

-Mahens

Categories: Silverlight Tags: ,
%d bloggers like this: