Simon Hewitt
04.11.2010
Hello,
We have reviewed this issue, and come to the conclusion that this is a MS bug. Our Bar class is the FrameworkContentElement descendant. However, the IsEnabledChanged event is raised only once when an item is added to the container. We belive that this is an incorrect behavior. I've attached a sample that illustrates that the same behavior can be reproduced with the standard controls. When I add the MyButtonInfo to the ItemsControl, the IsEnabledChanged event is raised, but when I changed the IsEnabled property for the parent, the IsEnabledChanged event isn't raised. We'll post this issue to MS.
Thank you, Marina
Well maybe there is an MS bug and maybe it isn't.
(I have a sneaking suspicion that this is something to do with logicaltree vs visualtree)
1) Your sample app still toggles the IsEnabled state even if the event isn't fired. My app's menu and toolbar stay permanently disabled so I'm not quite sure they are comparable.
2) As I mentioned originally, you seem to have added code specifically to NavBarControl to coerce the IsEnabled on the NavBarGroups and this all works fine. In fact, I just modified your sample app to do the same thing that NavBarControl does and now it fires the event on each change as I think you were expecting.
3) Looking in Reflector, IsEnabled (and IsHitTestVisible) seem to have special treatment - See the CoerceIsEnabled static method on UIElement for example and there are other instances of 'parent' controls coercing values onto their contained 'children'
Hello,
We'll update this issue when we get a feedback from the MS. The button is Enabled/Disabled because it is placed in a visual tree. Our Bar element isn't placed in a visual tree, because we place a BarControl there. The BarControl's Enabled property depends on the Bar's Enabled property. However, the Enabled property isn't changed for the Bar, and as a result the BarControl works incorrectly, too. We hope that MS fixes this issue. Please wait a little, we'll give a feedback ASAP.
Thank you, Marina
Is your intention to post an answer to your own question?
- If so, then proceed.
- If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
- If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.