Answering this a little late (2+ years), but hey, better late than never, right?
In any case, I ran into this exact problem and was able to solve it using code to save and reset the width of the columns.
I have a 3 column grid with some content in the first column, GridSplitter in the second column and Expander in the third column. It appears that after moving the GridSplitter, the width of the column containing the Expander changes from Auto to a fixed size. This causes the expander to no longer collapse as expected.
So, I added a private variable and two event handlers:
private GridLength _columnWidth; private void Expander_Expanded (object sender, RoutedEventArgs e) {
When Expander expands, I keep the column2 fixed in width (which was changed from auto-in the background somewhere), and then reset the width to auto.
Then, when the expander expands, I return the column back to a fixed width so that it expands to the same width before it is collapsed.
Here is the XAML for reference:
<Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="2*" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition x:Name="Column2" Width="Auto" /> </Grid.ColumnDefinitions> <ScrollViewer Grid.Column="0" VerticalScrollBarVisibility="Auto"> </ScrollViewer> <GridSplitter HorizontalAlignment="Right" VerticalAlignment="Stretch" Grid.Column="1" ResizeBehavior="PreviousAndNext" Width="5" Background="Black" /> <Expander Grid.Column="2" ExpandDirection="Left" IsExpanded="True" Style="{StaticResource LeftExpander}" Expanded="Expander_Expanded" Collapsed="Expander_Collapsed"> <Grid> <TextBox TextWrapping="Wrap" Height="Auto" Margin="0 5 5 5" /> </Grid> </Expander> </Grid>
Scott Marlowe Dec 14 '10 at 16:41 2010-12-14 16:41
source share