How do I stop inheritance in xaml?

Posted by cfouche on Stack Overflow See other posts from Stack Overflow or by cfouche
Published on 2010-03-15T18:53:32Z Indexed on 2010/03/16 7:06 UTC
Read the original article Hit count: 563

Filed under:
|
|
|

Hi

Let's say I have some Control that has been disabled. It contains a bunch of elements, but I want one of those child elements to remain enabled.

Something like this:

<ContentControl IsEnabled="False">
    <Border>
        <Button Content="Button" IsEnabled="True"/>
    </Border>
</ContentControl>

So in this example, the Button's IsEnabled="True" setting gets overridden by its parent. Is there a way of stopping this from happening?

This seems like a strange thing to be doing, but I have a situation where, when a Control is disabled and a user mouses down on it, I still want an event to be triggered.

I read in WPF Unleashed that wrapping something in a Frame control, "..isolates the content from the rest of the UI [and] properties that would normally be inherited down the element tree stop when they reach the Frame", but wrapping the Button in the example above in a Frame doesn't work.

Am I on the wrong track here?

© Stack Overflow or respective owner

Related posts about xaml

Related posts about wpf