This question is the same as this other unanswered question .
When the expander expands, the external ListView grows to make room for the contents of the expanders, but when Expander expands, the view does not resize the ListView.
Reduced code with notes after:
<!--<StackPanel>--> <ItemsControl> <!-- ParameterGroupView --> <Border BorderBrush="Brown" BorderThickness="1" CornerRadius="4" Padding="4"> <ListView HorizontalContentAlignment="Stretch"> <Expander Header="Expander A" IsExpanded="False"> <ListView HorizontalContentAlignment="Stretch"> <!-- TextView --> <TextBlock >Content A</TextBlock> <TextBlock >Content B</TextBlock> </ListView> </Expander> </ListView> </Border> </ItemsControl> <!--</StackPanel>-->
I have a ParameterGroupView in an ItemsControl or StackPanel, because there are actually a lot of ParameterGroupView entries. Switching to a StackPanel does not change the behavior.
Removing Boarder does not affect the behavior, but it helps to show the behavior with only one GroupView parameter.
An external ListView can have many Expander sections, and an Expander can have many objects inside an internal ListView.
The external ListView and Expander should replace the TreeView, which was used to have a list of replaceable nodes, but the internal use of TreeView grids means that the TextView elements were compressed horizontally, just as if you removed the ether HorizontalContentAlignment = "Stretch" attributes.
So, if there is another way to wrap it all up, I will be happy too.
This is a problem because our TextView blocks are large and there are many expanders.
Edit: TextView is used because the code is data bound and therefore dynamically merged. Therefore, for any ListView replacement, some form of ItemsSource is required.
listview wpf expander
Simeon pilgrim
source share