Enable or disable multiple controls in Silverlight

What's the best way to enable or disable multiple controls in Silverlight at the same time (text box, combo box, autocomplete, etc.)?

  • I suppose I can bind the IsEnabled property of each control to a boolean property. This property only exists for interactive controls, not text boxes.

  • I could recursively iterate over the children and set their properties correctly, but that seems inelegant.

  • Ideally I would like to just set some kind of disable-like property on the parent control container, which even disables the Windows Form-like TextBlocks.

Is there a way to disable the parent container?

+2


source to share


5 answers


You can use a ViewModel approach similar to the answer at fooobar.com/questions/2514134 / ...



With the computed IsEnabled property, you can bind the elements in the view that the property should control.

+3


source


Use ContentControl Silverlight.



<ContentControl x:Name="GroupOfControls" >...Your controls...</ContentControl>

//Enable and Disable
GroupOfControls.IsEnabled = false;

      

+4


source


I usually always create a ControlHandler class that does any updates to my controls. (Just to share concerns)

Lately, we had to reset the controls on all the form formats and didn't try to iterate over every control.

All control-related data logic information is updated in the ControlHandler class.

Then we apply only the values โ€‹โ€‹of the corresponding properties / properties to our controls.

This is a workaround, but it works very well and also clean for us.

There are, of course, better ways to fix this problem.

+1


source


I was looking for a way to disable multiple controls when fetching data from a web service. The BusyIndicator control got me what I needed with very little effort. Perhaps it will be a good solution for others.

+1


source


Wrap with UserControl and set its IsEnabled property.

       ...

0


source







All Articles