Reputation: 183
I have two Expanders (a right, and a left) within a dock panel (which has other elements as well). The dock panel content area can change size.
I'd like to be able to collapse either one of the two expanders, but if both are expanded, always have them be the same size - e.g. two equal columns. (Note: I already have code that expands the second if the first is collapsed, and vice versa.)
Is there a way to accomplish this without using hard-coded widths? I'm drawing a blank on the design to accomplish this. I've tried setting multi-data trigger on both ExpanderContents for the contents of each, but this just doesn't work.
e.g. on ExpanderContent1:
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=Expander1, Path=IsExpanded}" Value="True"/>
<Condition Binding="{Binding ElementName=Expander2, Path=IsExpanded}" Value="True"/>
</MultiDataTrigger.Conditions>
<Setter Property="Width" Value="{Binding ElementName=ExpanderContent2, Path=ActualWidth}"/>
</MultiDataTrigger>
Any ideas out there? Thanks in advance!
Upvotes: 2
Views: 551
Reputation: 487
If the content in the expanders is static you could nest your expanders in a two column Grid with each column width set to '*', but if the content is dynamic, this would break as an individual expander increases its size to accommodate the content.
Upvotes: 1
Reputation: 1843
try to bind the width of both as one, like if one is expanded other will increase in size. for example define row definition with minimum height and bind its height to a property, set this grid.row for both. now when height of one text box will increase other will also increase.
Upvotes: 0