views:

263

answers:

1

HI! I have an Expander and a TextBox. I want to disable the TextBox when the Expander is expanded and enable when it's not expanded. How to do that? I've tried something like this:

<TextBox IsEnabled="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Expander}, AncestorLevel=1},Path=IsExpanded}" />

But it's vice versa.

A: 

Try to remove the AncestorLevel property, it's error prone and usually not necessary

Thomas Levesque