Skip to main content

Microsoft Silverlight

Answered Question Enable/ disable different parts of a controlRSS Feed

(0)

karlssonkatrin
karlsson...

Member

Member

1 points

73 Posts

Enable/ disable different parts of a control

Hi

I have an app that contains different usercontrols. Sometimes I want to disable most part of the pages and just keep a couple buttons clickable. I tried to use both:

this.IsHitTestVisible = false;

btn_Cancel.IsHitTestVisible = true;

and IsEnabled. But btn_Cancel is never reset, it has the of the whole control.

Isn't it possible to override that value? Do I really need to set all part to false instead?

Regards Katrin 

 

elmore.adam
elmore.adam

Member

Member

482 points

67 Posts

Answered Question

Re: Enable/ disable different parts of a control

First, you should use the IsEnabled property to disable elements on your view. Read more about IsEnabled and IsHitTestVisible to understand the differences; essentially, by setting the IsEnabled property to false you will allow controls to display their "Disabled" state, whereas setting IsHitTestVisible to false will simply remove the ability to interact with the controls with a mouse. You will probably want to give the end users some sort of visual hint that the controls aren't active.

To answer your question, setting IsEnabled to false (or IsHitTestVisible for that matter) will affect all children elements. These are both properties of UIElement and as such you can set them on anything that derives from UIElement. Setting IsEnabled to false on the UserControl element would in turn disable all children elements on that view. No such override exists.

--
Kind Regards

Adam Elmore
MCTS: WPF, WCF

417.200.4261
elmore.adam@gmail.com
http://adamelmore.net/
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities